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

Apache's JIRA Issue Tracker | Luke Scott | 9 years ago
  1. 0

    [FILEUPLOAD-143] "Stream ended unexpectedly" when posting from a Flash client - ASF JIRA

    apache.org | 11 months ago
    org.apache.commons.fileupload.MultipartStream$MalformedStreamException: Stream ended unexpectedly
  2. 0

    I setup an upload script under a JSP. I tested it by uploading a file via html form upload and it worked fine - the file was received. But when I tried uploading the file through a flash interface using the FileReference object I got a 500 error response. Flash's FileReference API was very vague, and I was unable to reproduce the error under another interface so I could see the error.... But I finnally did get something back by writing a catch and writing the error to a file. I don't know if this is accurate or not: "Stream ended unexpectedly" I do know that the error occurs when this line is ran: List items = upload.parseRequest(request); And here is some relevant code, but not all of it: (to show that I do have a factory set): DiskFileItemFactory factory = new DiskFileItemFactory(); factory.setSizeThreshold(524288000); ServletFileUpload upload = new ServletFileUpload(factory); upload.setSizeMax(524288000); List items = upload.parseRequest(request); I am fairly sure that flash is doing something that is throwing commons-fileupload off. But it does work with apache & php... The biggest difference in the headers, or at least the initial headers, is flash passes a "connection: close" header. When searching I came up with some vague answers. This page shows some comments at the bottom by users with similar problems: http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002225.html One guy posts a solution to fix the problem, but it seems like it is severely out of date because where it says "return items;" I do not see items declared in the function of the line he mentions. Plus he mentions line 336, and it's now on 800 something. Tried his suggestion but instead returned "true" and "false" (tried both ways) but it didn't work... Also when I tried his catch line ant said it was invalid, so I had to put "Exception e" instead. You may notice that his post is in all caps (posts after his appear to be for some reason). I did make sure to use the proper case (i do know of case sensitivity). With further reading I read instances where flash did a "test upload" without sending the file. In other cases I read something about it not sending to blank lines after the header. Not sure what my current problem is.... I'm sure once the problem is found, it should be fairly trivial to fix (i hope). Even though it may be flash's fault, it works in PHP and other instances... So it should work here :) Thanks in advance, -Luke

    Apache's JIRA Issue Tracker | 9 years ago | Luke Scott
    org.apache.commons.fileupload.MultipartStream$MalformedStreamException: Stream ended unexpectedly
  3. 0

    I setup an upload script under a JSP. I tested it by uploading a file via html form upload and it worked fine - the file was received. But when I tried uploading the file through a flash interface using the FileReference object I got a 500 error response. Flash's FileReference API was very vague, and I was unable to reproduce the error under another interface so I could see the error.... But I finnally did get something back by writing a catch and writing the error to a file. I don't know if this is accurate or not: "Stream ended unexpectedly" I do know that the error occurs when this line is ran: List items = upload.parseRequest(request); And here is some relevant code, but not all of it: (to show that I do have a factory set): DiskFileItemFactory factory = new DiskFileItemFactory(); factory.setSizeThreshold(524288000); ServletFileUpload upload = new ServletFileUpload(factory); upload.setSizeMax(524288000); List items = upload.parseRequest(request); I am fairly sure that flash is doing something that is throwing commons-fileupload off. But it does work with apache & php... The biggest difference in the headers, or at least the initial headers, is flash passes a "connection: close" header. When searching I came up with some vague answers. This page shows some comments at the bottom by users with similar problems: http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002225.html One guy posts a solution to fix the problem, but it seems like it is severely out of date because where it says "return items;" I do not see items declared in the function of the line he mentions. Plus he mentions line 336, and it's now on 800 something. Tried his suggestion but instead returned "true" and "false" (tried both ways) but it didn't work... Also when I tried his catch line ant said it was invalid, so I had to put "Exception e" instead. You may notice that his post is in all caps (posts after his appear to be for some reason). I did make sure to use the proper case (i do know of case sensitivity). With further reading I read instances where flash did a "test upload" without sending the file. In other cases I read something about it not sending to blank lines after the header. Not sure what my current problem is.... I'm sure once the problem is found, it should be fairly trivial to fix (i hope). Even though it may be flash's fault, it works in PHP and other instances... So it should work here :) Thanks in advance, -Luke

    Apache's JIRA Issue Tracker | 9 years ago | Luke Scott
    org.apache.commons.fileupload.MultipartStream$MalformedStreamException: Stream ended unexpectedly
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    file upload fail using HTTP POST through C++

    Stack Overflow | 5 years ago | smita
    org.apache.commons.fileupload.MultipartStream$MalformedStreamException: Stream ended unexpectedly
  6. 0

    Android Image Upload Spring Multipart Exception

    Stack Overflow | 12 months ago | Lee
    org.apache.commons.fileupload.MultipartStream$MalformedStreamException: Stream ended unexpectedly

    3 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.apache.commons.fileupload.MultipartStream$MalformedStreamException

      Stream ended unexpectedly

      at org.apache.commons.fileupload.MultipartStream.readHeaders()
    2. Apache Commons FileUpload
      ServletFileUpload.parseRequest
      1. org.apache.commons.fileupload.MultipartStream.readHeaders(MultipartStream.java:542)
      2. org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.findNextItem(FileUploadBase.java:859)
      3. org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.hasNext(FileUploadBase.java:916)
      4. org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:348)
      5. org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:126)
      5 frames
    3. org.apache.jsp
      index_jsp._jspService
      1. org.apache.jsp.index_jsp._jspService(index_jsp.java:84)
      1 frame
    4. GWT dev
      HttpJspBase.service
      1. org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      1 frame
    5. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      1 frame
    6. GWT dev
      JspServlet.service
      1. org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
      2. org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
      3. org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
      3 frames
    7. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      1 frame
    8. Jetty Server
      SelectChannelEndPoint.run
      1. org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:491)
      2. org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:367)
      3. org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:185)
      4. org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
      5. org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:689)
      6. org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:391)
      7. org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:146)
      8. org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
      9. org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
      10. org.mortbay.jetty.Server.handle(Server.java:285)
      11. org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:457)
      12. org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:765)
      13. org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:627)
      14. org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:203)
      15. org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:357)
      16. org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:329)
      16 frames
    9. Jetty Util
      BoundedThreadPool$PoolThread.run
      1. org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:475)
      1 frame