Home java.lang.IllegalArgumentException: Request header is too large only for Spring Boot ReST services
Reply: 0

java.lang.IllegalArgumentException: Request header is too large only for Spring Boot ReST services

user3703 Published in March 21, 2018, 6:42 am

Have I got a weird one for you guys..

2 different implementation of webserices, hosted in the same container, different behavior with respect to HTTP headers

The client I work for have hundreds of webservices written very long time ago. They are all servlets exposed like webservices and they all look like this.

//Process the HTTP Post request
 public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
   doGet(request, response);
 }catch(Exception e){
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

  String stuff= request.getParameter("stuff");

The corresponding web.xml has the appropriate configuration to call the class based on url-pattern. Pretty standard.


Note: The "stuff" Query Parameter here can go up to 10k comma separated 6 digit numbers. The call is always POST.

Now, I was tasked to build a modern framework and migrate the code to it. So I design a simple Spring Boot application and use MVC controllers to expose ReST-like webservices. The only condition is the webservice signature should look like the existing service.

So, I go ahead and write this.

public class ResultsEndpoint {

@RequestMapping(value = "/ResultsServlet", method = RequestMethod.POST, produces = "application/xml")
    public void getProperties(@RequestParam("stuff") String stuff){


When the Query Parameters are too long, with around 10k 6 digit comma separated numbers, I am getting this error.

java.lang.IllegalArgumentException: Request header is too large at org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:515) at org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:504) at org.apache.coyote.http11.InternalInputBuffer.parseRequestLine(InternalInputBuffer.java:172) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1028) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)

Both the old and new webservices are hosted on the same Tomcat server. While the old one is working with large query parameters, the new one is erroring out.

So, I google and find out increasing the maxHttpHeaderSize in server.xml in tomcat from 8k to 64k would help fix the problem, and it does.

<Connector port="8080" protocol="HTTP/1.1"
           redirectPort="8443" maxHttpHeaderSize="65536"/>

They both use servlets at the end of the day, one is raw and other more refined and core implementation hidden.. Right? My client now wants to know why the old webservice works, but the new ones need change. As they are risk averse, they don't want to meddle with the server settings without knowing the whys.

Can someone help me figure out why the old webservice works for large Query Parameters but not the new ones?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.306949 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO