简体   繁体   中英

How big a war file should be?

Tomcat 7 manager limit the war file size to 50 Mo.

  • Why this limitation of 50 Mo ?
  • What should be the maximum war file size ? (in practice)

I'm working with Grails 2.2 which generate a minimal WAR of 28 Mo. So, the limit of 50 Min is very easy to reach.

This is only a limit set for you to upload and deploy via the Tomcat 7 manager. There really is not a limit on the size of the war file you can deploy to a tomcat server.

Here is a link that can help you increase this upload size.

Quoted from link --

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:

<!– 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>

If you're using Tomcat 8, the max-file-size is not in web.xml anymore. Instead, open conf/server.xml and find the tag entry for the HTTP connector. Then add the

maxPostSize="0"

attribute and value to this tag. When you have completed editing the conf/server.xml file, save it and restart Apache Tomcat.

The 50 MB default file size limit is not hard-coded, you can change it in the web.xml file of the Manager application of your webapp folder. You'll have to increase the max-file-size and max-request-size :

<!– 50MB max –>
<max-file-size>52428800</max-file-size>
<max-request-size>52428800</max-request-size>
<file-size-threshold>0</file-size-threshold>

Replace the current values with the appropriate values for your needs.

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 to for example 100Mb

In tomcat7, update the tomcat7/server.xml . I installed tomcat7 in ubuntu so the directory is like below

ll /etc/tomcat7/
total 220
drwxr-xr-x   4 root root      4096 Oct  6 18:14 ./
drwxr-xr-x 136 root root     12288 Oct  6 16:12 ../
drwxrwxr-x   3 root tomcat7   4096 Sep 23 15:44 Catalina/
-rw-r--r--   1 root tomcat7   6506 Jun 27 12:48 catalina.properties
-rw-r--r--   1 root tomcat7   1394 Jan 25  2014 context.xml
-rw-r--r--   1 root tomcat7   2370 Feb 18  2016 logging.properties
drwxr-xr-x   2 root tomcat7   4096 Sep 23 16:06 policy.d/
-rw-r--r--   1 root tomcat7   6716 Oct  6 18:14 server.xml
-rw-r-----   1 root tomcat7   1607 Sep 23 15:50 tomcat-users.xml
-rw-r--r--   1 root tomcat7 168099 Nov 25  2015 web.xml

You would see the connector section in the conf file etc/tomcat7/server.xml ,

<!-- A "Connector" represents an endpoint by which requests are received
     and responses are returned. Documentation at :
     Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
     Java AJP  Connector: /docs/config/ajp.html
     APR (HTTP/AJP) Connector: /docs/apr.html
     Define a non-SSL HTTP/1.1 Connector on port 8080
-->
<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           URIEncoding="UTF-8"
           redirectPort="8443"/>

Stop the tomcat and just add the maxPostSize at the end,

sudo service tomcat7 stop

Update the connector in the server.xml,

<!-- A "Connector" represents an endpoint by which requests are received
     and responses are returned. Documentation at :
     Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
     Java AJP  Connector: /docs/config/ajp.html
     APR (HTTP/AJP) Connector: /docs/apr.html
     Define a non-SSL HTTP/1.1 Connector on port 8080
-->
<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           URIEncoding="UTF-8"
           redirectPort="8443" 
           maxPostSize="57000000"/>

Then restart the tomcat.

sudo service tomcat7 start

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM