SpringBoot 上传文件突然报错 Failed to parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [/tmp/tomcat.1428942566812653608

异常信息

org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [/tmp/tomcat.1428942566812653608.8090/work/Tomcat/localhost/ROOT] is not valid
  at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.handleParseFailure(StandardMultipartHttpServletRequest.java:122)
  at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.parseRequest(StandardMultipartHttpServletRequest.java:113)
  at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.<init>(StandardMultipartHttpServletRequest.java:86)
  at org.springframework.web.multipart.support.StandardServletMultipartResolver.resolveMultipart(StandardServletMultipartResolver.java:93)
  at org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1128)
  at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:960)
  at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
  at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974)
  at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:877)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
  at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  at org.apache.catalina.filters.RemoteIpFilter.doFilter(RemoteIpFilter.java:876)
  at org.apache.catalina.filters.RemoteIpFilter.doFilter(RemoteIpFilter.java:913)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  at com.yooli.xcauto.heimdallrbackend.config.WebConfig$LoginPerssionmerFilter.doFilter(WebConfig.java:124)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
  at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
  at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
  at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
  at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1468)
  at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
  at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: The temporary upload location [/tmp/tomcat.1428942566812653608.8090/work/Tomcat/localhost/ROOT] is not valid
  at org.apache.catalina.connector.Request.parseParts(Request.java:2859)
  at org.apache.catalina.connector.Request.parseParameters(Request.java:3232)
  at org.apache.catalina.connector.Request.getParameter(Request.java:1137)
  at org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:381)
  at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:84)
  ... 23 more

分析原因

1.该异常是如何产生的
我是通过postman,发送一个post请求,导致该异常的。
从上面的异常信息来看,是因为该目录[/tmp/tomcat.1428942566812653608.8090/work/Tomcat/localhost/ROOT],不存在导致的。
2.该异常为何会产生
我的应用中没有文件上传,为啥会抛org.springframework.web.multipart.MultipartException异常
2.1)首先,我们应该知道,对于http POST请求来说,它需要使用这个临时目录来存储post数据。
2.2)其次,因为该目录是挂在到/temp目录下的临时文件,那么对于一些OS系统,像centOS将经常删除这个临时目录,所有导致该目录不存在了

解决方案

1.重启你的项目就可以了(我采用的这种)
你还可以尝试以下方式
2.在application.yml文件中设置multipart location ,并重启项目

spring:
  http:
    multipart:
      location: /data/upload_tmp

3.添加启动参数 -java.tmp.dir=/path/to/application/temp/,并重启

原文地址:https://www.cnblogs.com/jichi/p/12307160.html

时间: 2024-10-12 11:30:50

SpringBoot 上传文件突然报错 Failed to parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [/tmp/tomcat.1428942566812653608的相关文章

安装wps导致 application/kset 上传文件类型报错解决办法

电脑中安装wps上传execl时,上传.xls文件时 报错 application/kset 文件类型不正确 打印array() print_r($_FILES ) 结果如下: Array ( [userfile] => Array ( [name] => Template.xls[type] => application/kset[tmp_name] => C:\\Windows\\temp\\phpACC.tmp [error] => 0 [size] => 768

JDBC报错 消息 Could not get JDBC Connection; nested exception is java.sql.SQLException: Unknown system variable &#39;tx_isolation&#39;

今天用JDBCTemplate时,发现启动服务器之后报错: Could not get JDBC Connection; nested exception is java.sql.SQLException: Unknown system variable 'tx_isolation'. 网上说是因为MySQL版本过高的问题,我的MySQL版本是8.0,里面已经没有tx_isolation,变成了transaction_isolation,用了以下几种解决方法: (1)更改MySQL  无效,仍然

FTP上传文件,报错java.net.SocketException: Software caused connection abort: recv failed

FTP上传功能,使用之前写的代码,一直上传都没有问题,今天突然报这个错误: java.net.SocketException: Software caused connection abort: recv failed at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:152) at java.net.SocketIn

Hadoop上传文件的报错

baidu了很多,都说防火墙,datanode没有正常启动的问题,可是检查了都是正常,后来还是在老外的网站上找到了解决的方法 修改了/etc/security/limits.conf文件,上传成功 这些hadoop的报错都是莫名其妙,从这个日志无法看出是这个的问题,看来还是要自己慢慢积累 * soft nofile 65536 * hard nofile 65536 hadoop dfs -put 1.txt /input/ 报错日志如下: 15/06/24 14:45:40 WARN util

Ajax使用formdata异步上传文件,报错the request was rejected because no multipart boundary was found

基于jQuery的Ajaxs使用FormData上传文件要注意两个参数的设定 processData设为false 把processData设为false,让jquery不要对formData做处理,如果processData不设置为false,jquery会把formData转换为字符串. contentType设为false http发送multipart/form-data请求报文示例 POST /api/feed/ HTTP/1.1 Accept-Encoding: gzip Conte

解决上传到github报错Successfully created project &#39;autotest&#39; on GitHub, but initial commit failed:

通过IDEA上传代码到GitHub上可是有时候会碰到这样的问题. 当我们选择VCS->Import into Version Control->Share Project on GitHub提交代码.点击OK.然后就跳出了这样的信息: Can't finish GitHub sharing process Successfully created project 'autotest' on GitHub, but initial commit failed: *** Please tell m

SpringBoot 上传文件到linux服务器 异常java.io.FileNotFoundException: /tmp/tomcat.50898……解决方案

SpringBoot 上传文件到linux服务器报错java.io.FileNotFoundException: /tmp/tomcat.50898-- 报错原因: 解决方法 java.io.IOException: java.io.FileNotFoundException: /tmp/tomcat.5089835798184465073.8081/work/Tomcat/localhost/ROOT/www/server/apache-tomcat-8.5.32/webapps/jxmsto

springboot上传文件 &amp; 不配置虚拟路径访问服务器图片 &amp; springboot配置日期的格式化方式

1.    Springboot上传文件 springboot的文件上传不用配置拦截器,其上传方法与SpringMVC一样 @RequestMapping("/uploadPicture") @ResponseBody public JSONResultUtil uploadPicture(MultipartFile file, Integer viewId) { if (file == null) { return JSONResultUtil.error("文件没接到&q

记一次文件上传报错解决过程The temporary upload location is not vali

写一个文件上传接口,报了如下错误: Failed to parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [C:\Users\s0661\AppData\Local\Temp\tomcat.7304072307918184638.9997\work\Tomcat\localhost\ROOT] is not vali 这个博客解释得很清楚