You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Charlie DiDonato <cd...@nycap.rr.com> on 2024/12/16 22:02:25 UTC

maximum file upload size

Tomcat 10.1.26 on Windows

 

I getting a Tomcat error page (HTTP 413 - Payload too large) when trying to
upload a 372 Mb file for parsing and loading in my web app.

 

I have done the following:

Web.xml is modified for my Spring app as below

    <servlet>

        <servlet-name>dispatcher</servlet-name>

 
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-cl
ass>

        <load-on-startup>1</load-on-startup>

        <multipart-config>

            <max-file-size>1048576000</max-file-size> <!-- 1 GB -->

            <max-request-size>1048576000</max-request-size> <!-- 1 GB -->

            <file-size-threshold>0</file-size-threshold> <!-- 0 bytes -->

        </multipart-config>

    </servlet>

 

 

Server.xml is modified as below

    <Connector port="80" protocol="HTTP/1.1"

               connectionTimeout="20000"

               redirectPort="8443"

               maxParameterCount="1000"

               maxSwallowSize = "-1"

               />

 

 

 

Not sure what else there is to do.

Charlie DiDonato


Re: maximum file upload size

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Charlie,

On 12/17/24 2:59 PM, Charlie DiDonato wrote:
> On 12/16/24 5:02 PM, Charlie DiDonato wrote:
>> Tomcat 10.1.26 on Windows
>>
>> I getting a Tomcat error page (HTTP 413 - Payload too large) when
>> trying to upload a 372 Mb file for parsing and loading in my web app.
> 
> Do you have a stack trace to look at?
> 
>> I have done the following:
>>
>> Web.xml is modified for my Spring app as below
>>
>>       <servlet>
>>           <servlet-name>dispatcher</servlet-name>
>> <servlet-class>org.springframework.web.servlet.DispatcherServlet</serv
>> let-cl
>> ass>
>>           <load-on-startup>1</load-on-startup>
>>           <multipart-config>
>>               <max-file-size>1048576000</max-file-size> <!-- 1 GB -->
>>               <max-request-size>1048576000</max-request-size> <!-- 1 GB -->
>>               <file-size-threshold>0</file-size-threshold> <!-- 0 bytes -->
>>           </multipart-config>
>>       </servlet>
> 
> Are you sure the "dispatcher" servlet is the one handling the request?
> 
> -chris
> 
> There is no stack trace in the Tomcat logs but I find this in my application log.
> It might NOT be Tomcat itself but rather my Spring configuration.
> I though it might be Tomcat because it was a Tomcat Error page.
> 
> What do you think about below?
> Charlie
> 
> 2024-12-17 13:38:56,682 TRACE o.s.w.s.DispatcherServlet [http-nio-80-exec-1] POST "/codereaper/snomed/snomedFileUpload", parameters={multipart}, headers={masked} in DispatcherServlet 'dispatcher'
> 2024-12-17 13:38:56,729 WARN o.s.w.s.m.s.DefaultHandlerExceptionResolver [http-nio-80-exec-1] Resolved [org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size exceeded]
> 2024-12-17 13:38:56,729 TRACE o.s.w.s.DispatcherServlet [http-nio-80-exec-1] No view rendering, null ModelAndView returned.
> 2024-12-17 13:38:56,729 DEBUG o.s.w.s.DispatcherServlet [http-nio-80-exec-1] Completed 413 PAYLOAD_TOO_LARGE, headers={}
> 
> 
> 
> Here is what I did to resolve.........not a Tomcat problem but a Spring issue

Agreed: Spring is the component which is objecting to the file size.

> 1. commented out dispatcher servlet in web.xml as there was already a dispatcher servlet in the app initializer class
> 2.  Added a multipart config in the app initializer code as below
> 
> @EnableWebSecurity
> public class CodereaperWebAppInitializer implements WebApplicationInitializer {
> 	
> 	private static final String TMP_FOLDER = "c:/1";
>      private static final int MAX_UPLOAD_SIZE = 1000 * 1024 * 1024;  //1 Gb
> 	
>      @Override
>      public void onStartup(ServletContext container) {
>          AnnotationConfigWebApplicationContext context
>            = new AnnotationConfigWebApplicationContext();
>          context.setConfigLocation("com.empirestateids.configuration");
> 
>          container.addListener(new ContextLoaderListener(context));
> 
>          ServletRegistration.Dynamic dispatcher = container
>            .addServlet("dispatcher", new DispatcherServlet(context));
>          
>          dispatcher.setLoadOnStartup(1);
>          dispatcher.addMapping("/");
>          
>          MultipartConfigElement multipartConfigElement = new MultipartConfigElement(TMP_FOLDER,
>                  MAX_UPLOAD_SIZE, MAX_UPLOAD_SIZE * 2L, 0);
>                
>          dispatcher.setMultipartConfig(multipartConfigElement);
>          
>          
>      }
> }

That sounds plausible. I know nothing about Spring, though :)

That temp folder looks sketchy to me.


-chris


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: maximum file upload size

Posted by Charlie DiDonato <cd...@nycap.rr.com>.
Chris,

-----Original Message-----
From: Charlie DiDonato <cd...@nycap.rr.com> 
Sent: Tuesday, December 17, 2024 1:43 PM
To: 'Tomcat Users List' <us...@tomcat.apache.org>
Subject: RE: maximum file upload size

Chris

-----Original Message-----
From: Christopher Schultz <ch...@christopherschultz.net>
Sent: Tuesday, December 17, 2024 12:54 PM
To: users@tomcat.apache.org
Subject: Re: maximum file upload size

Charlie,

On 12/16/24 5:02 PM, Charlie DiDonato wrote:
> Tomcat 10.1.26 on Windows
> 
> I getting a Tomcat error page (HTTP 413 - Payload too large) when 
> trying to upload a 372 Mb file for parsing and loading in my web app.

Do you have a stack trace to look at?

> I have done the following:
> 
> Web.xml is modified for my Spring app as below
> 
>      <servlet>
>          <servlet-name>dispatcher</servlet-name>
> <servlet-class>org.springframework.web.servlet.DispatcherServlet</serv
> let-cl
> ass>
>          <load-on-startup>1</load-on-startup>
>          <multipart-config>
>              <max-file-size>1048576000</max-file-size> <!-- 1 GB -->
>              <max-request-size>1048576000</max-request-size> <!-- 1 GB -->
>              <file-size-threshold>0</file-size-threshold> <!-- 0 bytes -->
>          </multipart-config>
>      </servlet>

Are you sure the "dispatcher" servlet is the one handling the request?

-chris

There is no stack trace in the Tomcat logs but I find this in my application log.
It might NOT be Tomcat itself but rather my Spring configuration.
I though it might be Tomcat because it was a Tomcat Error page.

What do you think about below?
Charlie

2024-12-17 13:38:56,682 TRACE o.s.w.s.DispatcherServlet [http-nio-80-exec-1] POST "/codereaper/snomed/snomedFileUpload", parameters={multipart}, headers={masked} in DispatcherServlet 'dispatcher'
2024-12-17 13:38:56,729 WARN o.s.w.s.m.s.DefaultHandlerExceptionResolver [http-nio-80-exec-1] Resolved [org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size exceeded]
2024-12-17 13:38:56,729 TRACE o.s.w.s.DispatcherServlet [http-nio-80-exec-1] No view rendering, null ModelAndView returned.
2024-12-17 13:38:56,729 DEBUG o.s.w.s.DispatcherServlet [http-nio-80-exec-1] Completed 413 PAYLOAD_TOO_LARGE, headers={}



Here is what I did to resolve.........not a Tomcat problem but a Spring issue
1. commented out dispatcher servlet in web.xml as there was already a dispatcher servlet in the app initializer class
2.  Added a multipart config in the app initializer code as below

@EnableWebSecurity
public class CodereaperWebAppInitializer implements WebApplicationInitializer {
	
	private static final String TMP_FOLDER = "c:/1"; 
    private static final int MAX_UPLOAD_SIZE = 1000 * 1024 * 1024;  //1 Gb
	
    @Override
    public void onStartup(ServletContext container) {
        AnnotationConfigWebApplicationContext context
          = new AnnotationConfigWebApplicationContext();
        context.setConfigLocation("com.empirestateids.configuration");

        container.addListener(new ContextLoaderListener(context));

        ServletRegistration.Dynamic dispatcher = container
          .addServlet("dispatcher", new DispatcherServlet(context));
        
        dispatcher.setLoadOnStartup(1);
        dispatcher.addMapping("/");
        
        MultipartConfigElement multipartConfigElement = new MultipartConfigElement(TMP_FOLDER, 
                MAX_UPLOAD_SIZE, MAX_UPLOAD_SIZE * 2L, 0);
              
        dispatcher.setMultipartConfig(multipartConfigElement);
        
        
    }
    
}


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: maximum file upload size

Posted by Charlie DiDonato <cd...@nycap.rr.com>.
Chris

-----Original Message-----
From: Christopher Schultz <ch...@christopherschultz.net> 
Sent: Tuesday, December 17, 2024 12:54 PM
To: users@tomcat.apache.org
Subject: Re: maximum file upload size

Charlie,

On 12/16/24 5:02 PM, Charlie DiDonato wrote:
> Tomcat 10.1.26 on Windows
> 
> I getting a Tomcat error page (HTTP 413 - Payload too large) when 
> trying to upload a 372 Mb file for parsing and loading in my web app.

Do you have a stack trace to look at?

> I have done the following:
> 
> Web.xml is modified for my Spring app as below
> 
>      <servlet>
>          <servlet-name>dispatcher</servlet-name>
> <servlet-class>org.springframework.web.servlet.DispatcherServlet</serv
> let-cl
> ass>
>          <load-on-startup>1</load-on-startup>
>          <multipart-config>
>              <max-file-size>1048576000</max-file-size> <!-- 1 GB -->
>              <max-request-size>1048576000</max-request-size> <!-- 1 GB -->
>              <file-size-threshold>0</file-size-threshold> <!-- 0 bytes -->
>          </multipart-config>
>      </servlet>

Are you sure the "dispatcher" servlet is the one handling the request?

-chris

There is no stack trace in the Tomcat logs but I find this in my application log.
It might NOT be Tomcat itself but rather my Spring configuration.
I though it might be Tomcat because it was a Tomcat Error page.

What do you think about below?
Charlie

2024-12-17 13:38:56,682 TRACE o.s.w.s.DispatcherServlet [http-nio-80-exec-1] POST "/codereaper/snomed/snomedFileUpload", parameters={multipart}, headers={masked} in DispatcherServlet 'dispatcher'
2024-12-17 13:38:56,729 WARN o.s.w.s.m.s.DefaultHandlerExceptionResolver [http-nio-80-exec-1] Resolved [org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size exceeded]
2024-12-17 13:38:56,729 TRACE o.s.w.s.DispatcherServlet [http-nio-80-exec-1] No view rendering, null ModelAndView returned.
2024-12-17 13:38:56,729 DEBUG o.s.w.s.DispatcherServlet [http-nio-80-exec-1] Completed 413 PAYLOAD_TOO_LARGE, headers={}
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: maximum file upload size

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Charlie,

On 12/16/24 5:02 PM, Charlie DiDonato wrote:
> Tomcat 10.1.26 on Windows
> 
> I getting a Tomcat error page (HTTP 413 - Payload too large) when trying to
> upload a 372 Mb file for parsing and loading in my web app.

Do you have a stack trace to look at?

> I have done the following:
> 
> Web.xml is modified for my Spring app as below
> 
>      <servlet>
>          <servlet-name>dispatcher</servlet-name>
> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-cl
> ass>
>          <load-on-startup>1</load-on-startup>
>          <multipart-config>
>              <max-file-size>1048576000</max-file-size> <!-- 1 GB -->
>              <max-request-size>1048576000</max-request-size> <!-- 1 GB -->
>              <file-size-threshold>0</file-size-threshold> <!-- 0 bytes -->
>          </multipart-config>
>      </servlet>

Are you sure the "dispatcher" servlet is the one handling the request?

-chris


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org