1. Error log
org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is java.lang.RuntimeException: java.nio.file.NoSuchFileException: /tmp/undertow.8081.6091954911906268442/undertow2435234810596519507upload
at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.handleParseFailure(StandardMultipartHttpServletRequest.java:124)
at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.parseRequest(StandardMultipartHttpServletRequest.java:115)
at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.<init>(StandardMultipartHttpServletRequest.java:88)
at org.springframework.web.multipart.support.StandardServletMultipartResolver.resolveMultipart(StandardServletMultipartResolver.java:87)
at org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1178)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1012)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
2. Cause of problem
After consulting the blog, I know the cause of the problem:
in Linux system, when the spring boot application is started with Java jar command, a Tomcat (or undertow) temporary directory will be generated in the/tmp directory of the operating system. The uploaded files must be converted into temporary files and saved under this folder. Because the files in the temporary/tmp directory are not used for a long time (10 days), the system executes the TMP directory cleaning service (systemd-tmpfiles-clean. Service), resulting in the cleaning of/TMP/undertow… 8090 files. However, when uploading, the undertow server needs to create/TMP/undertow… 8090/undertow… Upload temporary files, However, when calling files. CreateFile (…), you will find that the parent directory cannot be found, which leads to the above error.
3. Solution
1) Restart
cannot be done once and for all
2) the directory specified by the configuration file
needs to be manually created on the server
MKDIR – P/data/tmp
spring:
servlet:
multipart:
location: /data/tmp
3) Add startup parameter – Java.TMP.Dir =/path/to/application/temp/
Read More:
- [Solved] Upload Files Error: Request processing failed;nested exception is org.springframework.web.multipart.MultipartExcepti
- Request processing failed; nested exception is java.lang.NullPointerException or UnsatisfiedDependencyE
- [Solved] Failed to start bean ‘eurekaAutoServiceRegistration‘; nested exception is java.lang.NullPointerExce
- [Solved] Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException
- [Solved] nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter
- Error resolution: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/Datatype
- [Solved] swagger Failed to start bean ‘documentationPluginsBootstrapper‘; nested exception is java.lang.NullP
- [Solved] Failed to start bean ‘documentationPluginsBootstrapper‘; nested exception is java.lang.NullPointerEx
- [Solved] Invocation of init method failed; nested exception is java.lang.NoSuchMethodError:
- [Solved] nacos Startup Error: nested exception is java.lang.RuntimeException: java.lang.RuntimeException: [db-load-error
- [Solved] ApiPost Error: org.springframework.web.multipart.MultipartException
- nested exception is java.lang.StackOverflowError [How to Solve]
- [Solved] Failed to bind properties under ‘spring.servlet.multipart.file-size-threshold‘ to
- SpringCloud Use openFeign Multipartfile to Upload Files Error: Current request is not a multipart request
- [Solved] org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is
- [Solved] JAVA Project Import jstl Error: java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/TagLibraryValidator
- I/O error while reading input message; nested exception is java.io.IOException: Stream closed
- [Solved] nested exception is org.apache.ibatis.builder.BuilderException: Error invoking SqlProvider method
- [Solved] eureka Startup Error: Unable to start web … nested exception is org.springframework.boot.web.server.WebS
- [Solved] eureka Startup Error: Unable to start web … nested exception is org.springframework.boot.web.server.WebS