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.