0

I am facing a very strange behavior. I am packing up my jar into a container to deploy it on ECS, however, it seems like my application.yaml is not taking effect when it comes to define the max-file-size to 100M.

oddly it works just fine when launch the application either locally or by executing the fat jar.

Here's my application.yaml

spring:
  http.multipart:
    max-file-size: 100MB
    max-request-size: 100MB

Dockerfile

FROM openjdk:8-jre-alpine
ARG JAR_FILE
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-Dspring.profiles.active=prod","-jar","/app.jar"]

The error on AWS

{
  "timestamp": 1535489967123,
  "status": 500,
  "error": "Internal Server Error",
  "exception": "org.springframework.web.multipart.MultipartException",
  "message": "Could not parse multipart servlet request; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (43258070) exceeds the configured maximum (10485760)",
  "path": "/fake/path/loader"
}
Victor Hugo Montes
  • 1,270
  • 1
  • 17
  • 28

1 Answers1

0

The issue is mostly with you application.yaml not getting packaged correctly. As an alternative you can use command line override for you spring jar in following fashion :

java -jar your-app.jar --spring.http.multipart.max-file-size=100MB --spring.http.multipart.max-request-size=100MB

or you can refer to external application file loading as mentioned in this answer : External Application Props

jazz
  • 509
  • 7
  • 16