Chris,

-----Original Message-----
From: Charlie DiDonato <cdido...@nycap.rr.com> 
Sent: Tuesday, December 17, 2024 1:43 PM
To: 'Tomcat Users List' <users@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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



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



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

Reply via email to