我使用Jetty容器部署了Spring / Mvc,最近在生产中我无法上传文件,失败的原因是缺少/ tmp目录。
我重新启动应用程序以修复它,但它再次随机丢失。
以下是我在上传过程中遇到的例外情况。
2015-07-03 06:58:22,440|qtp1182373735-15|INFO |o.s.s.ldap.SpringSecurityLdapTemplate: Ignoring PartialResultException
2015-07-03 06:58:22,494|qtp1182373735-15|ERROR|c.n.b.w.e.GlobalControllerExceptionHandler: Could not parse multipart servlet request; nested exception is org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. /tmp/jetty-0.0.0.0-8999-booster-_booster-any-1796299670201591887.dir/upload_5a19924c_c3a7_4f1f_8a46_702d1faa4c1a_00000001.tmp (No such file or directory)
org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. /tmp/jetty-0.0.0.0-8999-booster-_booster-any-1796299670201591887.dir/upload_5a19924c_c3a7_4f1f_8a46_702d1faa4c1a_00000001.tmp (No such file or directory)
at org.springframework.web.multipart.commons.CommonsMultipartResolver.parseRequest(CommonsMultipartResolver.java:165) ~[spring-web-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.web.multipart.commons.CommonsMultipartResolver.resolveMultipart(CommonsMultipartResolver.java:142) ~[spring-web-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1067) ~[spring-webmvc-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:906) ~[spring-webmvc-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870) ~[spring-webmvc-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961) [spring-webmvc-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863) [spring-webmvc-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) [javax.servlet-api-3.1.0.jar:3.1.0]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837) [spring-webmvc-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [javax.servlet-api-3.1.0.jar:3.1.0]
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:711) [jetty-servlet-9.1.3.v20140225.jar:9.1.3.v20140225]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1644) [jetty-servlet-9.1.3.v20140225.jar:9.1.3.v20140225]
at org.springframework.security.oauth2.client.filter.OAuth2ClientContextFilter.doFilter(OAuth2ClientContextFilter.java:57) [spring-security-oauth2-2.0.2.RELEASE.jar:na]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1632) [jetty-servlet-9.1.3.v20140225.jar:9.1.3.v20140225]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) [spring-security-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) [spring-security-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) [spring-security-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) [spring-security-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:201) [spring-security-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110) [spring-security-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) [spring-security-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) [spring-security-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) [spring-security-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344) [spring-web-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261) [spring-web-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1632) [jetty-servlet-9.1.3.v20140225.jar:9.1.3.v20140225]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) [spring-web-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.0.5.RELEASE.jar:4.0.5.RELEASE]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1632) [jetty-servlet-9.1.3.v20140225.jar:9.1.3.v20140225]
at com.codahale.metrics.servlet.AbstractInstrumentedFilter.doFilter(AbstractInstrumentedFilter.java:97) [metrics-servlet-3.0.2.jar:3.0.2]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1624) [jetty-servlet-9.1.3.v20140225.jar:9.1.3.v20140225]
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:550) [jetty-servlet-9.1.3.v20140225.jar:9.1.3.v20140225]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) [jetty-server-9.1.3.v20140225.jar:9.1.3.v20140225]
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:568) [jetty-security-9.1.3.v20140225.jar:9.1.3.v20140225]
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221) [jetty-server-9.1.3.v20140225.jar:9.1.3.v20140225]
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1112) [jetty-server-9.1.3.v20140225.jar:9.1.3.v20140225]
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:479) [jetty-servlet-9.1.3.v20140225.jar:9.1.3.v20140225]
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183) [jetty-server-9.1.3.v20140225.jar:9.1.3.v20140225]
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1046) [jetty-server-9.1.3.v20140225.jar:9.1.3.v20140225]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [jetty-server-9.1.3.v20140225.jar:9.1.3.v20140225]
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:199) [jetty-server-9.1.3.v20140225.jar:9.1.3.v20140225]
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109) [jetty-server-9.1.3.v20140225.jar:9.1.3.v20140225]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [jetty-server-9.1.3.v20140225.jar:9.1.3.v20140225]
at org.eclipse.jetty.server.Server.handle(Server.java:462) [jetty-server-9.1.3.v20140225.jar:9.1.3.v20140225]
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:281) [jetty-server-9.1.3.v20140225.jar:9.1.3.v20140225]
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:232) [jetty-server-9.1.3.v20140225.jar:9.1.3.v20140225]
at org.eclipse.jetty.io.AbstractConnection$1.run(AbstractConnection.java:505) [jetty-io-9.1.3.v20140225.jar:9.1.3.v20140225]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:607) [jetty-util-9.1.3.v20140225.jar:9.1.3.v20140225]
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:536) [jetty-util-9.1.3.v20140225.jar:9.1.3.v20140225]
at java.lang.Thread.run(Thread.java:724) [na:1.7.0_40]
Caused by: org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. /tmp/jetty-0.0.0.0-8999-booster-_booster-any-1796299670201591887.dir/upload_5a19924c_c3a7_4f1f_8a46_702d1faa4c1a_00000001.tmp (No such file or directory)
at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:351) ~[commons-fileupload-1.3.1.jar:1.3.1]
at org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:115) ~[commons-fileupload-1.3.1.jar:1.3.1]
at org.springframework.web.multipart.commons.CommonsMultipartResolver.parseRequest(CommonsMultipartResolver.java:158) ~[spring-web-4.0.5.RELEASE.jar:4.0.5.RELEASE]
... 56 common frames omitted
Caused by: java.io.FileNotFoundException: /tmp/jetty-0.0.0.0-8999-booster-_booster-any-1796299670201591887.dir/upload_5a19924c_c3a7_4f1f_8a46_702d1faa4c1a_00000001.tmp (No such file or directory)
at java.io.FileOutputStream.open(Native Method) ~[na:1.7.0_40]
at java.io.FileOutputStream.<init>(FileOutputStream.java:221) ~[na:1.7.0_40]
at java.io.FileOutputStream.<init>(FileOutputStream.java:171) ~[na:1.7.0_40]
at org.apache.commons.io.output.DeferredFileOutputStream.thresholdReached(DeferredFileOutputStream.java:178) ~[commons-io-2.4.jar:2.4]
at org.apache.commons.io.output.ThresholdingOutputStream.checkThreshold(ThresholdingOutputStream.java:224) ~[commons-io-2.4.jar:2.4]
at org.apache.commons.io.output.ThresholdingOutputStream.write(ThresholdingOutputStream.java:128) ~[commons-io-2.4.jar:2.4]
at org.apache.commons.fileupload.util.Streams.copy(Streams.java:107) ~[commons-fileupload-1.3.1.jar:1.3.1]
at org.apache.commons.fileupload.util.Streams.copy(Streams.java:70) ~[commons-fileupload-1.3.1.jar:1.3.1]
at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:347) ~[commons-fileupload-1.3.1.jar:1.3.1]
... 58 common frames omitted
答案 0 :(得分:0)
您的/tmp
目录正在被其他一些进程定期清理。
一个很常见的场景。
将webapp的临时目录设置为/tmp
以外的其他位置(又名java.io.tmpdir
。
See prior answer about your options on how to setup a temp directory for your webapp.