1

I have been facing this problem as given below.

HTTP Status 500 - Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.lang.IllegalStateException: The multi-part request contained parameter data (excluding uploaded files) that exceeded the limit for maxPostSize set on the associated connector

I have gone through other threads of similar question and I have also implemented the below in my Application configuration file.

@Bean
EmbeddedServletContainerCustomizer containerCustomizer() throws Exception {
    return (ConfigurableEmbeddedServletContainer container) -> {
        if (container instanceof TomcatEmbeddedServletContainerFactory) {
            TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;
            tomcat.addConnectorCustomizers(
                    (connector) -> {
                        connector.setMaxPostSize(500000000);
                        connector.setSecure(true);
                        connector.setScheme("https");
                        connector.setRedirectPort(443);
                    }
            );
        }
    };
}

When I am running on my local machine, it is working perfectly fine as it is using Embedded Tomcat.

But the real problem is when I host my application onto AWS Elastic Beanstalk, I get the above error.

I am using Amazon EC2 instance which automatically comes with Elastic beanstalk Tomcat environment.

So my guess is the above configuration is not working on AWS as it is not Embedded Tomcat?

Please guide me where I am going wrong and how to resolve this issue.

Santhosh Raj
  • 153
  • 3
  • 13
  • I can confirm this happens outside of amazon usage, and spring-boot configuration does not properly propagate the configuration to tomcat. – Kieveli Jul 26 '17 at 16:04

1 Answers1

-2

Try these settings on application.properties:

multipart.maxFileSize: 500MB
multipart.maxRequestSize: 500MB

Ref.: https://spring.io/guides/gs/uploading-files/

Hugo Baés
  • 433
  • 13
  • 19
  • Probably Amazon have some restrictive configurations on their Beanstalk Tomcat instance. Maybe if you run your own tomcat instance you could change the connector settings. – Hugo Baés Aug 01 '16 at 13:42
  • You are right Hugo! We need to edit pre-defined configuration files and I am not able to figure it out. – Santhosh Raj Aug 02 '16 at 14:01
  • Maybe this answer can help: http://stackoverflow.com/a/14484045/2406724 – Hugo Baés Aug 02 '16 at 16:23
  • 1
    I have already done this Hugo. There is another file called httpd.conf where all the config things are done. – Santhosh Raj Aug 12 '16 at 06:07