zoukankan      html  css  js  c++  java
  • Spring Boot报错 MultipartException The temporary upload...

    Spring Boot报错:尤其是在处理Ribbon这类接口调用型的负载均衡组件,常见问题

    ERROR 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: Could not parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [/tmp/tomcat.1222167204409692266.8781/work/Tomcat/localhost/ROOT] is not valid] with root cause
    java.io.IOException: The temporary upload location [/tmp/tomcat.1222167204409692266.8781/work/Tomcat/localhost/ROOT] is not valid
            at org.apache.catalina.connector.Request.parseParts(Request.java:2877)
            at org.apache.catalina.connector.Request.parseParameters(Request.java:3242)
            at org.apache.catalina.connector.Request.getParameter(Request.java:1136)
            at org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:381)
            at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:84)
            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:197)
            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.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:103)
            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:493)
            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:800)
            at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
            at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
            at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
            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) 

     原因有二:

    • The http POST methods will use these temp location to store the post data.
    • http post接口请求参数需要保存到服务器临时路径
    • Some OS like centOS will delete the temp dir frequently. SO even you set that location's permission, after some time, that dir will be removed by OS. And after you reboot, the temp dir will be different.
    • 常用的云服务器如centOS,定期会删除这些临时路径,且每次重启路径不同.因此,需指定临时保存路径

      处理如下:

    spring:
      # post 接口 临时目录设置,避免被操作系统清除
      http:
        multipart:
          location: /data/upload_tmp
  • 相关阅读:
    oracle数据类型
    hive的union,hive连接查询的优化,mapjoin的设置参数
    hive分隔符
    hive load数据到表的方式
    hive的常用命令操作与数据类型以及hive的严格模式
    hadoop fs 与 dfs 的区别
    pl/sql程序语法,存储过程, orcle服务
    mysql连接启动
    HTTP协议
    php6
  • 原文地址:https://www.cnblogs.com/nyatom/p/10601142.html
Copyright © 2011-2022 走看看