Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What causes java.lang.IllegalStateException: Post too large in tomcat / mod_jk

what configuration needs to be tweaked, and where does it live, in order to increase the maximum allowed post size?

like image 909
masukomi Avatar asked Sep 23 '08 19:09

masukomi


People also ask

What is the default heap size in Tomcat 9?

For particularly large models it is possible to run out of memory since the Java Virtual Machine (JVM) used by Apache Tomcat sets the maximum heap size to only 64 MB by default.

What is maxPostSize in Tomcat?

maxPostSize. The maximum size in bytes of the POST which will be handled by the container FORM URL parameter parsing. The limit can be disabled by setting this attribute to a value less than zero. If not specified, this attribute is set to 2097152 (2 megabytes).

How does Tomcat optimize performance in production?

To improve performance, Tomcat is configured by default to cache static resources. However, the size of the cache must be configured to be large enough to provide performance savings. To tune Tomcat's cache settings, find the Context directive (in server. xml or context.

What is maxHttpHeaderSize?

maxHttpHeaderSize. The maximum size of the request and response HTTP header, specified in bytes. If not specified, this attribute is set to 8192 (8 KB). maxKeepAliveRequests. The maximum number of HTTP requests which can be pipelined until the connection is closed by the server.


2 Answers

Apache Tomcat by default sets a limit on the maximum size of HTTP POST requests it accepts. In Tomcat 5, this limit is set to 2 MB. When you try to upload files larger than 2 MB, this error can occur.

The solution is to reconfigure Tomcat to accept larger POST requests, either by increasing the limit, or by disabling it. This can be done by editing [TOMCAT_DIR]/conf/server.xml. Set the Tomcat configuration parameter maxPostSize for the HTTPConnector to a larger value (in bytes) to increase the limit. Setting it to 0 in will disable the size check. See the Tomcat Configuration Reference for more information.

like image 174
Steve K Avatar answered Oct 21 '22 03:10

Steve K


It will be for others persons, I see you are coupling Apache HTTP and Tomcat (tomcat / mod_jk), in this case edit the Coyote/JK2 AJP 1.3 Connector the same way you do it for the standard connector (Coyote HTTP/1.1), because the AJP1.3 Connector is where Tomcat receive data.

<!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
<Connector port="8009" 
           enableLookups="false" redirectPort="8443" debug="0"
           protocol="AJP/1.3" maxPostSize="0"/>
like image 28
Ahmed MANSOUR Avatar answered Oct 21 '22 03:10

Ahmed MANSOUR