[JAVA] Spring boot temporary upload location [/ tmp / tomcat ・ ・ ・ is not valid]

Event

A file upload that was always working suddenly stopped working one day.

error contents

application.log


ERROR 39865 --- [http-nio-20080-exec-6] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is 
org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is java.io.IOException:
The temporary upload location [/tmp/tomcat.12071915071708668548.20080/work/Tomcat/localhost/ROOT] is not valid] with root cause

Cause

The OS deleted the directory used by Spring embedded Tomcat as a temporary folder (WORK when uploading files, etc.). .. (It was covered with the directory to be deleted by the OS) Therefore, suddenly there is no temporary folder to use when uploading. This time I was using CentOS. In the case of embedded Tomcat, the temporary folder is created in /tmp/tomcat.xxxxxx by default (automatically generated when tomcat starts).

Correspondence

Change temporary folder from / tmp

application.yml


server:
  tomcat:
    basedir: /xxx/xxxx/xxxx   #Specify the path here

Recommended Posts

Spring boot temporary upload location [/ tmp / tomcat ・ ・ ・ is not valid]
Spring Boot 2.0.0 does not start built-in tomcat
File upload with Spring Boot (do not use Multipart File)
File upload with Spring Boot
What is @Autowired in Spring boot?
What is a Spring Boot .original file?
Try Spring Boot 1 (Environment construction ~ Tomcat startup)