简体   繁体   English

无法解析多部分 servlet 请求

[英]Could not parse multipart servlet request

When I tried to download file with my code, I have this error :当我尝试使用我的代码下载文件时,出现以下错误:

HTTP Status 500 - Request processing failed; HTTP 状态 500 - 请求处理失败; nested exception is org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request;嵌套异常是 org.springframework.web.multipart.MultipartException:无法解析多部分 servlet 请求; nested exception is java.io.IOException: The temporary upload location [/tmp/tomcat.5139949927832460132.8080/work/Tomcat/localhost/ROOT] is not valid嵌套异常是 java.io.IOException:临时上传位置 [/tmp/tomcat.5139949927832460132.8080/work/Tomcat/localhost/ROOT] 无效

I did not understand how this can be do.我不明白这是怎么做到的。 I try to create the directory but same way.我尝试以相同的方式创建目录。 I try to reboot the VM bue same way.我尝试以相同的方式重新启动 VM。

I have this in the log :我在日志中有这个:

org.springframework.web.util.NestedServletException: 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.5139949927832460132.8080/work/Tomcat/localhost/ROOT] is not valid
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:105)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:89)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:107)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
root cause

org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [/tmp/tomcat.5139949927832460132.8080/work/Tomcat/localhost/ROOT] is not valid
    org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.parseRequest(StandardMultipartHttpServletRequest.java:111)
    org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.<init>(StandardMultipartHttpServletRequest.java:85)
    org.springframework.web.multipart.support.StandardServletMultipartResolver.resolveMultipart(StandardServletMultipartResolver.java:76)
    org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1099)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:932)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:105)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:89)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:107)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
root cause

java.io.IOException: The temporary upload location [/tmp/tomcat.5139949927832460132.8080/work/Tomcat/localhost/ROOT] is not valid
    org.apache.catalina.connector.Request.parseParts(Request.java:2776)
    org.apache.catalina.connector.Request.parseParameters(Request.java:3176)
    org.apache.catalina.connector.Request.getParameter(Request.java:1110)
    org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:381)
    org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:70)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:107)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

Can you help me please ?你能帮我吗?

Thanks in advance !提前致谢!

You can specify override the /tmp folder by modifying the start.sh script:您可以通过修改 start.sh 脚本来指定覆盖 /tmp 文件夹:

JVM_OPTIONS="-Xrs -Xms256m -Xmx512m -Djava.io.tmpdir=/opt/tridion/deployer-live/tmp" The first three options (-Xrs -Xms256m -Xmx512m) are out of the box, I just added '-Djava.io.tmpdir=/opt/tridion/deployer-live/tmp'. JVM_OPTIONS="-Xrs -Xms256m -Xmx512m -Djava.io.tmpdir=/opt/tridion/deployer-live/tmp" 前三个选项(-Xrs -Xms256m -Xmx512m)是开箱即用的,我只是添加了'- Djava.io.tmpdir=/opt/tridion/deployer-live/tmp'。

The tomcat home folder and docbase folder are now created in the location that I specified, and the cleanup script can no longer do any harm.现在在我指定的位置创建了 tomcat 主文件夹和 docbase 文件夹,并且清理脚本不再有任何危害。

source https://tridion.stackexchange.com/a/14325来源https://tridion.stackexchange.com/a/14325

credits @Quirijn学分@Quirijn

It is recommended to specify custom directory path for temp storage through spring (or server) configuration.建议通过spring(或server)配置为临时存储指定自定义目录路径。

But quick hack would be to create the mentioned directory and provide the read/write permissions as但是快速破解是创建提到的目录并提供读/写权限

mkdir -p /tmp/tomcat.5139949927832460132.8080/work/Tomcat/localhost/ROOT

chmod 755 /tmp/tomcat.5139949927832460132.8080/work/Tomcat/localhost/ROOT

tomcat.xxxxxxxxxxxx.xxxx - This will be different on each server. tomcat.xxxxxxxxxxxx.xxxx - 这在每个服务器上都不同。 Use this directory name from your server error.使用服务器错误中的此目录名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring MVC - 使用Ajax上传多部分文件(无法解析多部分servlet请求) - Spring MVC - Multipart file upload with Ajax (Could not parse multipart servlet request) 无法解析多部分 servlet 请求;.IllegalStateException:无法处理部分,因为未提供多部分配置 - Could not parse multipart servlet request;.IllegalStateException: Unable to process parts as no multi-part configuration has been provided 文件上传中断时“无法解析多部分 servlet 请求” - "Failed to parse multipart servlet request" when file uploading interrupted Servlet Multipart请求的问题 - Issue with Servlet Multipart request servlet处理的多部分图像上传发布请求 - Multipart Image upload post request processed by servlet 提交multipart / form-data时Servlet请求contenttype = null - Servlet request contenttype = null when submitting multipart/form-data servlet为什么在多部分请求中找不到FileItem? - Why doesn't servlet find FileItem in multipart request? Java servlet无法接收http post multipart请求的部分 - Java servlet can't receive the parts of an http post multipart request Java Servlet解析请求主体多线程 - Java Servlet parse request body multithread 在Java中解析包含multipart / form-data请求体的String - Parse a String containing multipart/form-data request body in Java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM