• 文件上传异常Stream ended unexpectedly

    普通类
    • 支持
    • 批判
    • 提问
    • 解释
    • 补充
    • 删除
    • 错误信息

    org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. Stream ended unexpectedly

    at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:371)

    at org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:126)

    at com.fredck.FCKeditor.uploader.SimpleUploaderServlet.processUpload(SimpleUploaderServlet.java:191)

    at com.fredck.FCKeditor.uploader.SimpleUploaderServlet.doPost(SimpleUploaderServlet.java:312)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)

    at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)

    at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)

    at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:381)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    at etc.struts.filter.ChooseWebsiteFilter.doFilter(ChooseWebsiteFilter.java:295)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    at hep.webapp.struts.EncodingFilter.doFilter(EncodingFilter.java:48)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    at hep.webapp.struts.CheckAdminLoginFilter.doFilter(CheckAdminLoginFilter.java:155)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    at hep.webapp.struts.CheckLoginFilter.doFilter(CheckLoginFilter.java:360)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

    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:191)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

    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:298)

    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)

    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)

    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)

    at java.lang.Thread.run(Thread.java:619)

    Caused by: org.apache.commons.fileupload.MultipartStream$MalformedStreamException: Stream ended unexpectedly

    at org.apache.commons.fileupload.MultipartStream$ItemInputStream.makeAvailable(MultipartStream.java:982)

    at org.apache.commons.fileupload.MultipartStream$ItemInputStream.read(MultipartStream.java:886)

    at java.io.InputStream.read(InputStream.java:85)

    at org.apache.commons.fileupload.util.Streams.copy(Streams.java:96)

    at org.apache.commons.fileupload.util.Streams.copy(Streams.java:66)

    at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:366)

    ... 35 more

    • 问题分析

    1、根据标红的部分分析,是流意外中断所导致的。

    2、再根据打印的错误堆栈,是SimpleUploaderServlet中的List items = upload.parseRequest(request);这句话出现问题。

    根据这两个提示,应该是用户在编辑器中上传文件的时候未完成就中断上传导致的。

    • 解决方案

    对于用户主动中断的文件上传,后台只能捕获这样的异常,然后做出相应的处理。所以现在时在程序中捕获这个异常,而不再打印异常的堆栈信息。

    关于java中捕获多个异常的注意事项请查看:

    http://lcell.bnu.edu.cn/do/lcpage?action=view&koId=9008

    • 标签:
    • 235
    • org.apache.catalina.core.applicationfilterchain.dofilter
    • org.apache.commons.fileupload.multipartstream
    • org.apache.catalina.core.applicationfilterchain.internaldofilter
    • 206
    • 中断
    • applicationfilterchain.java
    • 异常
    • 捕获
    • 上传
  • 加入的知识群:
    学习元评论 (0条)

    评论为空
    聪明如你,不妨在这 发表你的看法与心得 ~



    登录之后可以发表学习元评论
      
暂无内容~~
顶部