Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FileUploadBase$SizeLimitExceededException apache tomcat

Tags:

tomcat

tomcat7

Im trying to upload file from a JSP file and I get the following error in catalina.out. As specified in many blogs, I increased the the max-file-size under webapps/manager/WEB-INF/web.xml but still I have the same problem...Where should I increase it to resolve this error?

<multipart-config>
      <!-- 50MB max -->
      <max-file-size>5242880000000</max-file-size>
      <max-request-size>5242880000000</max-request-size>
      <file-size-threshold>0</file-size-threshold>
    </multipart-config>

org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (341297) exceeds the configured maximum (51200)
like image 768
user1050619 Avatar asked Sep 10 '14 20:09

user1050619


People also ask

How to increase max post size in Tomcat?

xml configuration file. By default Tomcat limits POST data to 2 MB. This limit can cause an issue when you use rule sets, which can post data greater than this limit. To disable the POST limit in Tomcat, you can add the maxPostSize="-1" attribute to the <Connector> element of the server.

How to increase war file size in Tomcat?

You need to change the max-file-size and max-request-size to a value larger than the war file you are trying to deploy (e.g. change it from 52428800 to 157286400 which would change the max size from 50MB to 150MB) and restart the web server.


3 Answers

I had the same problem. I solved it by setting the parameter maxPostSize in the http server tomcat connector located in <tomcat-root-folder>/conf/server.xml as follows:

<Connector connectionTimeout="20000" 
           port="8080" 
           protocol="HTTP/1.1" 
           redirectPort="8443" 
           maxPostSize="52428800" />

Set maxPostSize to 52428800 increase the upload file size to 50 MB. By default it's set to 2 MB.

For more explanation, read this: https://tomcat.apache.org/tomcat-7.0-doc/config/http.html

like image 66
Jean Dok Avatar answered Oct 13 '22 00:10

Jean Dok


https://maxrohde.com/2011/04/27/large-war-file-cannot-be-deployed-in-tomcat-7/

Go to the web.xml of the manager application (for instance it could be under /tomcat7/webapps/manager/WEB-INF/web.xml. Increase the max-file-size and max-request-size:

<multipart-config>
<!– 50MB max –>
<max-file-size>52428800</max-file-size>
<max-request-size>52428800</max-request-size>
<file-size-threshold>0</file-size-threshold>
</multipart-config>
like image 36
Gene Avatar answered Oct 13 '22 02:10

Gene


This is configured in web.xml for the manager app.

Ex:

  <servlet>
    <servlet-name>HTMLManager</servlet-name>
    <servlet-class>org.apache.catalina.manager.HTMLManagerServlet</servlet-class>
    <init-param>
      <param-name>debug</param-name>
      <param-value>2</param-value>
    </init-param>
    <multipart-config>
      <!-- 50MB max -->
      <max-file-size>52428800</max-file-size>
      <max-request-size>52428800</max-request-size>
      <file-size-threshold>0</file-size-threshold>
    </multipart-config>
  </servlet>

https://github.com/apache/tomcat/blob/7.0.x/webapps/manager/WEB-INF/web.xml#L56-L57

The manager app uses the Servlet 3.0 API. If you're using commons file upload directly, it's up to you and you need to configure this manually.

like image 7
Daniel Mikusa Avatar answered Oct 13 '22 01:10

Daniel Mikusa