After some days of runtime, your Spring Boot application with Embedded Tomcat might mysteriously partly stop working, with the following exception:
org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [**/tmp/tomcat.1220970741172837513.8080/work/Tomcat/localhost/ROOT]** is not valid at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.parseRequest(StandardMultipartHttpServletRequest.java:111)
If you have this issue, you may want to check whether you’re using multipart requests, as the exception indicates. That is, receiving
MultiValueMaps in your endpoints. Tomcat serves these as file uploads by storing the parts
in a temporary folder: under
It turns out that various services may clear the
/tmp folder every fixed number of days, as there should be no harm in throwing out old files. In my case, that was 10 days on AWS EC2.
In fact, there is an issue about this, asking Spring Boot to recreate the embedded Tomcat file handles if the
The only solution found so far, until Spring solves the issue, is to make sure /tmp does not get cleared, by making it larger or not on the root partition.