I guess in that respect, it is similar to bug: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25598
but I am running Justin Sampson's patch of: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=30061 but it doesn't work for this problem. Possibly this problem, is more related to IIS 6.0 on Windows 2003 Server? Here is the JUNIT Output from when I built the fileupload jar today. They complete successfully: internal-test: [junit] Running org.apache.commons.fileupload.DefaultFileItemTest [junit] Tests run: 6, Failures: 0, Errors: 0, Time elapsed: 0.296 sec [junit] Testsuite: org.apache.commons.fileupload.DefaultFileItemTest [junit] Tests run: 6, Failures: 0, Errors: 0, Time elapsed: 0.296 sec [junit] Testcase: testTextFieldConstruction took 0 sec [junit] Testcase: testFileFieldConstruction took 0 sec [junit] Testcase: testBelowThreshold took 0.016 sec [junit] Testcase: testAboveThresholdDefaultRepository took 0 sec [junit] Testcase: testAboveThresholdSpecifiedRepository took 0 sec [junit] Testcase: testContentCharSet took 0.015 sec [junit] Running org.apache.commons.fileupload.FileUploadTest [junit] Tests run: 5, Failures: 0, Errors: 0, Time elapsed: 0.312 sec [junit] Testsuite: org.apache.commons.fileupload.FileUploadTest [junit] Tests run: 5, Failures: 0, Errors: 0, Time elapsed: 0.312 sec [junit] Testcase: testWithInvalidRequest took 0.047 sec [junit] Testcase: testWithNullContentType took 0 sec [junit] Testcase: testFileUpload took 0.015 sec [junit] Testcase: testEmptyFile took 0 sec [junit] Testcase: testIE5MacBug took 0 sec [junit] Running org.apache.commons.fileupload.MultipartStreamTest [junit] Tests run: 4, Failures: 0, Errors: 0, Time elapsed: 0.266 sec [junit] Testsuite: org.apache.commons.fileupload.MultipartStreamTest [junit] Tests run: 4, Failures: 0, Errors: 0, Time elapsed: 0.266 sec [junit] Testcase: testDefaultConstructor took 0.016 sec [junit] Testcase: testThreeParamConstructor took 0 sec [junit] Testcase: testTwoParamConstructor took 0 sec [junit] Testcase: testToString took 0 sec [junit] Running org.apache.commons.fileupload.ParameterParserTest [junit] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 0.265 sec [junit] Testsuite: org.apache.commons.fileupload.ParameterParserTest [junit] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 0.265 sec [junit] Testcase: testParsing took 0 sec [junit] Testcase: testContentTypeParsing took 0 sec [junit] Testcase: testParsingEscapedChars took 0 sec -----Original Message----- From: Robert Priest Sent: Thursday, October 28, 2004 2:13 PM To: Jakarta Commons Users List; Dakota Jack Subject: RE: FileUpload\Windows 2003 Server\Tomcat looks like the else statement here in: MultipartStream.java is occurring. (from MutipartStream.readBodyData(OutputStream output)): bytesRead = input.read(buffer, pad, bufSize - pad); // [pprrrrrrr] if (bytesRead != -1) { tail = pad + bytesRead; } else { // The last pad amount is left in the buffer. // Boundary can't be in there so write out the // data you have and signal an error condition. output.write(buffer, 0, pad); output.flush(); total += pad; throw new MalformedStreamException( "Stream ended unexpectedly"); } Here it is the stack trace: 13:43:32,962,ERROR: FileUploadBase FileUploadBase e.getMessage() = Stream ended unexpectedly org.apache.commons.fileupload.MultipartStream$MalformedStreamException: Stream ended unexpectedly at org.apache.commons.fileupload.MultipartStream.readBodyData(MultipartStre am.java:552) at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase .java:360) at com.projectwise.web.server.lite.formhandler.FormHandler.arrangeRequest(F ormHandler.java:655) at com.projectwise.web.server.lite.formhandler.FormHandler.processRequest(F ormHandler.java:3856) at com.projectwise.web.server.lite.LiteServlet.doGet(LiteServlet.java:470) at com.projectwise.web.server.lite.LiteServlet.doPost(LiteServlet.java:527) at javax.servlet.http.HttpServlet.service(HttpServlet.java:760) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica tionFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt erChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv e.java:260) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4 80) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv e.java:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4 80) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:235 0) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java :180) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherVa lve.java:170) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java :171) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4 80) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve. java:174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4 80) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223) at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:256) at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:361) at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:565) at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java: 537) at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:640) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool .java:533) at java.lang.Thread.run(Thread.java:536) -----Original Message----- From: Dakota Jack [mailto:[EMAIL PROTECTED] Sent: Thursday, October 28, 2004 12:10 PM To: Jakarta Commons Users List Subject: Re: FileUpload\Windows 2003 Server\Tomcat I would suggest that you go into FileUploadBase and flesh out the exceptions so that you can get more information. Try something like the following: /* try {*/ int boundaryIndex = contentType.indexOf("boundary="); if (boundaryIndex < 0) { throw new FileUploadException( "the request was rejected because " + "no multipart boundary was found"); } byte[] boundary = contentType.substring( boundaryIndex + 9).getBytes(); InputStream input = null; MultipartStream multi = null; boolean nextPart = false; try { input = req.getInputStream(); multi = new MultipartStream(input, boundary); multi.setHeaderEncoding(headerEncoding); nextPart = multi.skipPreamble(); } catch(IOException ioe) { YOURLOGGER("log.error","FileUploadBase (88) ioe.getMessage() = " + ioe.getMessage()); } while (nextPart) { Map headers = null; try { headers = parseHeaders(multi.readHeaders()); } catch (MalformedStreamException mse) { YOURLOGGER("log.error","FileUploadBase mse.getMessage() = " + mse.getMessage()); } String fieldName = getFieldName(headers); if (fieldName != null) { String subContentType = getHeader(headers, CONTENT_TYPE); if (subContentType != null && subContentType.startsWith(MULTIPART_MIXED)) { // Multiple files. byte[] subBoundary = subContentType.substring( subContentType .indexOf("boundary=") + 9).getBytes(); boolean nextSubPart = false; try { multi.setBoundary(subBoundary); nextSubPart =multi.skipPreamble(); } catch (MalformedStreamException mse) { YOURLOGGER("log.error","FileUploadBase mse.getMessage() = " + mse.getMessage()); } catch (IllegalBoundaryException ibe) { YOURLOGGER("log.error","FileUploadBase ibe.getMessage() = " + ibe.getMessage()); } catch (IOException ioe) { YOURLOGGER("log.error","FileUploadBase ioe.getMessage() = " + ioe.getMessage()); } while (nextSubPart) { try { headers = parseHeaders(multi.readHeaders()); } catch (MalformedStreamException mse) { YOURLOGGER("log.error","FileUploadBase mse.getMessage() = " + mse.getMessage()); } if (getFileName(headers) != null) { FileItem item = createItem(headers, false); OutputStream os = null; try { os = item.getOutputStream(); multi.readBodyData(os); } catch (IOException ioe) { YOURLOGGER("log.error","FileUploadBase ioe.getMessage() = " + ioe.getMessage()); } finally { try { os.close(); } catch (IOException ioe) { YOURLOGGER("log.error","FileUploadBase ioe.getMessage() = " + ioe.getMessage()); } } items.add(item); } else { // Ignore anything but files inside // multipart/mixed. try { multi.discardBodyData(); } catch (MalformedStreamException mse) { YOURLOGGER("log.error","FileUploadBase mse.getMessage() = " + mse.getMessage()); } catch (IOException ioe) { YOURLOGGER("log.error","FileUploadBase ioe.getMessage() = " + ioe.getMessage()); } } try { nextSubPart = multi.readBoundary(); } catch (MalformedStreamException mse) { YOURLOGGER("log.error","FileUploadBase mse.getMessage() = " + mse.getMessage()); } } try { multi.setBoundary(boundary); } catch (IllegalBoundaryException ibe) { YOURLOGGER("log.error","FileUploadBase ibe.getMessage() = " + ibe.getMessage()); } } else { if (getFileName(headers) != null) { // A single file. FileItem item = createItem(headers, false); OutputStream os = null; try { os = item.getOutputStream(); multi.readBodyData(os); } catch (IOException ioe) { YOURLOGGER("log.error","FileUploadBase ioe.getMessage() = " + ioe.getMessage()); } finally { try { os.close(); } catch(IOException ioe) { YOURLOGGER("log.error","FileUploadBase ioe.getMessage() = " + ioe.getMessage()); } } items.add(item); } else { // A form field. FileItem item = createItem(headers, true); OutputStream os = null; try { os = item.getOutputStream(); multi.readBodyData(os); } catch(IOException ioe) { YOURLOGGER("log.error","FileUploadBase ioe.getMessage() = " + ioe.getMessage()); } finally { try { os.close(); } catch (IOException ioe) { YOURLOGGER("log.error","FileUploadBase ioe.getMessage() = " + ioe.getMessage()); } } items.add(item); } } } else { // Skip this part. try { multi.discardBodyData(); } catch (MalformedStreamException mse) { YOURLOGGER("log.error","FileUploadBase mse.getMessage() = " + mse.getMessage()); } catch (IOException ioe) { YOURLOGGER("log.error","FileUploadBase ioe.getMessage() = " + ioe.getMessage()); } } try { nextPart = multi.readBoundary(); } catch (MalformedStreamException mse) { YOURLOGGER("log.error","FileUploadBase mse.getMessage() = " + mse.getMessage()); } } /* } catch (IOException e) { throw new FileUploadException( "Processing of " + MULTIPART_FORM_DATA + " request failed. " + e.getMessage()); }*/ Seem right? Jack On Thu, 28 Oct 2004 10:30:13 -0400, Robert Priest <[EMAIL PROTECTED]> wrote: > Hello Dakota Jack, > > I am using the latest version of fileupload > (commons-fileupload-1.1-dev.jar), which is using the latest version of > commons-io-1.1-dev.jar > > The code for getTempFile() in the latest version of DefaultFileItem, > looks like this: > > /** > * Creates and returns a [EMAIL PROTECTED] java.io.File File} representing a > uniquely > * named temporary file in the configured repository path. The > lifetime of > * the file is tied to the lifetime of the <code>FileItem</code> > instance; > * the file will be deleted when the instance is garbage collected. > * > * @return The [EMAIL PROTECTED] java.io.File File} to be used for temporary > storage. > */ > protected File getTempFile() > { > File tempDir = repository; > if (tempDir == null) > { > tempDir = new File(System.getProperty("java.io.tmpdir")); > } > > String fileName = "upload_" + getUniqueId() + ".tmp"; > > File f = new File(tempDir, fileName); > FileCleaner.track(f, this); > return f; > } > > That FileCleaner, is out of commons-io-1.1-dev.jar. > > I think you may be on to something with the point about the threshold. > Another point about this problem is that if the file is 51KB or less, > it works fine. > However, If I try it with a file of 52 KB or more, it fails. Any idea? > > I did check the tmpdir, and it has been created. > Indeed, the 51 KB file is uploaded correctly to the exact same > directory. > > However 52 KB, fails. > > Here is how I call upload: > > // Create a new file upload handler > DiskFileUpload upload = new DiskFileUpload(); > // Set upload parameters > upload.setSizeMax(-1); //no limit > upload.setSizeThreshold(4096); > upload.setRepositoryPath(importDir); > upload.setHeaderEncoding("UTF-8"); > // Parse the request > List items = null; > try > { > items = upload.parseRequest(hsrRequest); > } > catch(Exception e) > { > mLog.log("Encountered Situation parsing file > upload request",LogConstants.LEVEL_ERROR,e); > } > > And here is the stack trace I get back when it fails (when filesize > > 51 > KB) > > > > NDC: > Category: com.projectwise.web.server.lite.LiteServlet > Message: Encountered Situation parsing file upload > request > Location: > Thrown: > org.apache.commons.fileupload.FileUploadException: Processing of > multipart/form-data request failed. Stream ended unexpectedly > at > org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBa > se > .java:364) > at > com.projectwise.web.server.lite.formhandler.FormHandler.arrangeRequest > (F > ormHandler.java:655) > at > com.projectwise.web.server.lite.formhandler.FormHandler.processRequest > (F > ormHandler.java:3856) > at > com.projectwise.web.server.lite.LiteServlet.doGet(LiteServlet.java:470) > at > com.projectwise.web.server.lite.LiteServlet.doPost(LiteServlet.java:527) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:760) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appli > ca > tionFilterChain.java:247) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFi > lt > erChain.java:193) > at > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVa > lv > e.java:260) > at > org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext > .i > nvokeNext(StandardPipeline.java:643) > at > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java > :4 > 80) > at > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) > at > org.apache.catalina.core.StandardContextValve.invoke(StandardContextVa > lv > e.java:191) > at > org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext > .i > nvokeNext(StandardPipeline.java:643) > at > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java > :4 > 80) > at > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) > at > org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2 > 35 > 0) > at > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.ja > va > :180) > at > org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext > .i > nvokeNext(StandardPipeline.java:643) > at > org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcher > Va > lve.java:170) > at > org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext > .i > nvokeNext(StandardPipeline.java:641) > at > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.ja > va > :171) > at > org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext > .i > nvokeNext(StandardPipeline.java:641) > at > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java > :4 > 80) > at > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) > at > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve. > java:174) > at > org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext > .i > nvokeNext(StandardPipeline.java:643) > at > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java > :4 > 80) > at > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) > at > org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223) > at > org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:256) > at > org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:361) > at > org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:565) > at > org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java: > 537) > at > org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:640) > at > org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPo > ol > .java:533) > at java.lang.Thread.run(Thread.java:536) > > > > > -----Original Message----- > From: Dakota Jack [mailto:[EMAIL PROTECTED] > Sent: Wednesday, October 27, 2004 7:53 PM > To: Jakarta Commons Users List > Subject: Re: FileUpload\Windows 2003 Server\Tomcat > > What is your code for his, Robert? And, what is the stack trace of > the error? It looks like the problem is in OutputStream os = > item.getOutputStream(); and this goes back to > > protected File getTempFile() > { > File tempDir = repository; > if (tempDir == null) > { > tempDir = new File(System.getProperty("java.io.tmpdir")); > } > > String fileName = "upload_" + getUniqueId() + ".tmp"; > > File f = new File(tempDir, fileName); > f.deleteOnExit(); > return f; > } > > Have you checked out your temporary directory? Or, I think there is > something about the threshold only being used for certain things. > > Jack > > On Wed, 27 Oct 2004 18:01:11 -0400, Robert Priest > <[EMAIL PROTECTED]> wrote: > > Hello, I am running a version of tomcat 4.1 on Windows 2003 Server > > and > > > I keep getting the following problem from the > > > > DiskFileUpload.parseRequest() call: > > > > Date: Wed Oct 27 17:23:18 EDT 2004 (1098912198367) > > Thread: Thread-11 > > Message #: 274 > > Level: ERROR > > NDC: > > Category: com.projectwise.web.server.lite.LiteServlet > > Message: Encountered Situation parsing file upload > > request > > Location: > > Thrown: > > org.apache.commons.fileupload.FileUploadException: Processing of > > multipart/form-data request failed. Stream ended unexpectedly > > at > > org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUpload > > Ba > > se > > .java:364) > > at > > com.projectwise.web.server.lite.formhandler.FormHandler.arrangeReque > > st > > (F > > ormHandler.java:655) > > ... > > > > This code works fine on other machines (w2k, XP, etc). I am only > > seeing this when I am running on a Windows 2003 Server. > > > > It seems to happen when on > > > > FileUploadBase line:349 > > > > finally > > { > > line 349: --> os.close(); > > } > > > > the original exception is a > > > > org.apache.commons.fileupload.MultipartStream$MalformedStreamExcepti > > on > > "Stream ended unexpectedly" > > > > is anyone else seeing this issue? > > > > I am using a version of fileupload which I compiled today from the > > cvs repository. > > > > it is: commons-fileupload-1.1-dev.jar > > > > Does anyone have any suggestions? > > > > I would appreciate the help. Thanks. > > > > Robert. > > > > -------------------------------------------------------------------- > > - To unsubscribe, e-mail: > > [EMAIL PROTECTED] > > For additional commands, e-mail: > > [EMAIL PROTECTED] > > > > > > -- > "You can't wake a person who is pretending to be asleep." > > ~Native Proverb~ > > "Each man is good in His sight. It is not necessary for eagles to be > crows." > > ~Hunkesni (Sitting Bull), Hunkpapa Sioux~ > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- "You can't wake a person who is pretending to be asleep." ~Native Proverb~ "Each man is good in His sight. It is not necessary for eagles to be crows." ~Hunkesni (Sitting Bull), Hunkpapa Sioux~ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
