ClientAbortException:大文件上载期间的java.io.IOException

时间:2013-06-05 05:46:41

标签: java spring file-upload

我有一个Spring应用程序,用户上传大文件(超过300 MB)。在当地,它的工作非常好。但是,当我尝试在Live中使用我的应用程序时,大部分时间它都会失败(有时它会成功)。这是控制台的日志。任何人都可以帮助我摆脱错误。我正在使用JQuery Chunk文件上传功能。服务器是Tomcat 6。

17:02:28,395 DEBUG SessionFactoryUtils:793 - Closing Hibernate Session
File Path:/home/borneind/ty/uploads/7397758850/2190167412/1366559675908_06 - Mergel - Mergedelica.wav
17:02:31,036 DEBUG ExceptionHandlerExceptionResolver:132 - Resolving exception from handler [public void com.jmacksoft.common.controller.TranceController.getDocumentFileContent(javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpServletRequest,java.lang.String,java.lang.String,java.lang.String,java.lang.String) throws java.io.IOException]: ClientAbortException:  java.io.IOException
17:02:31,037 DEBUG ResponseStatusExceptionResolver:132 - Resolving exception from handler [public void com.jmacksoft.common.controller.TranceController.getDocumentFileContent(javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpServletRequest,java.lang.String,java.lang.String,java.lang.String,java.lang.String) throws java.io.IOException]: ClientAbortException:  java.io.IOException
17:02:31,037 DEBUG DefaultHandlerExceptionResolver:132 - Resolving exception from handler [public void com.jmacksoft.common.controller.TranceController.getDocumentFileContent(javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpServletRequest,java.lang.String,java.lang.String,java.lang.String,java.lang.String) throws java.io.IOException]: ClientAbortException:  java.io.IOException
17:02:31,038 DEBUG DispatcherServlet:910 - Could not complete request
ClientAbortException:  java.io.IOException
    at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:358)
    at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:434)
    at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:349)
    at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:381)
    at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:370)
    at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:89)
    at org.springframework.util.FileCopyUtils.copy(FileCopyUtils.java:113)
    at com.jmacksoft.common.controller.TranceController.getDocumentFileContent(TranceController.java:603)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:212)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:852)
    at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:584)
    at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1508)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.io.IOException
    at org.apache.coyote.http11.InternalAprOutputBuffer.flushBuffer(InternalAprOutputBuffer.java:692)
    at org.apache.coyote.http11.InternalAprOutputBuffer$SocketOutputBuffer.doWrite(InternalAprOutputBuffer.java:722)
    at org.apache.coyote.http11.filters.IdentityOutputFilter.doWrite(IdentityOutputFilter.java:118)
    at org.apache.coyote.http11.InternalAprOutputBuffer.doWrite(InternalAprOutputBuffer.java:528)
    at org.apache.coyote.Response.doWrite(Response.java:560)

1 个答案:

答案 0 :(得分:2)

根据页面被查看超过2000次的事实唤醒僵尸 我确信原始海报太迟了,但对于未来的读者来说,这是你的解决方案。

如果您正在使用jquery,则需要为异步请求设置更长的超时值才能完成。这个blog entry提供了一种方法。在您的情况下,您没有登录,但示例应该为您提供所需。引用帖子......

function SuccessFunction(data, status) {

          var obj = jQuery.parseJSON(data.d);
          if (obj.Success == “true”) {
              writeConsole(‘logging in’);
              $.ajax({
                  type: “GET”,
                  url: ‘<% Response.Write(url); %>?’ + obj.UserNameAndPassword,
                  dataType: ‘jsonp’,
                  complete: function() {
                      $.mobile.changePage(“#success”, { transition: “fade” });
                  },
                  timeout: 5000 // sets timeout to 5 seconds
              });
          }
          else {
              $(“#popupFail”).popup(“open”, { transition: “fade” });
              writeConsole(‘login failure ‘);
          }
          return;
      }

...我建议找到一种方法来集中这个值,而不是在整个脚本中任意地使用它。注意不要在受限环境中选择太短的超时。您的开发经验几乎总是比野外的体验更好。