commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sandy Shah" <>
Subject File Upload Exception - Why is parseRequest() returning no items?
Date Sun, 30 Mar 2008 05:46:46 GMT
Hey guys,


I am trying to upload a .doc file via a java application from the client
which is my local drive to a webserver where the application resides.  I am
using the apache.commons.file and am getting this error:


29 Mar 2008 19:38:55,355 [DEBUG] xxxxxx.servlets.uploadFil (ExecuteThread:
'21' for queue: 'weblogic.kernel.Default') doPost

29 Mar 2008 19:38:55,356 [DEBUG] xxxxxx.servlets.uploadFil (ExecuteThread:
'21' for queue: 'weblogic.kernel.Default') ***Request is multipart: Http
Request: /it0030/uploadDoc

29 Mar 2008 19:38:55,356 [DEBUG] xxxxxx.servlets.uploadFil (ExecuteThread:
'21' for queue: 'weblogic.kernel.Default') ***Set threshhold and temp

29 Mar 2008 19:38:55,356 [DEBUG] xxxxxx.servlets.uploadFil (ExecuteThread:
'21' for queue: 'weblogic.kernel.Default') ****failed to load items from req


This is what I am doing:


I have an HTML form with input type = "file" with browse and submit.  The
form is "multipart/form-data".  The form action invokes a servlet.  This is
the code in the servlet doPost event:


        if(isMultiPart(req)) {

            log.debug("***Request is multipart: "+req.toString());



        DiskFileItemFactory factory = new DiskFileItemFactory();


        factory.setRepository(new File("c:/tmp"));


        ServletFileUpload fu = new ServletFileUpload(factory);


        log.debug("***Set threshhold and temp location");


       List fileItems = null;

       try {           

           fileItems = fu.parseRequest(req);

       } catch (FileUploadException e) {         

                        log.debug("****failed to load items from req");   



When I run it I get the debug messages in the application log and my
application hangs.  


After some research I found 2 possible reasons this could happen but do not
know why it happens and how to correct the problem.

1) Per the API, parseRequest throws FileUploadException - if there are
problems reading/parsing the request or storing files.

2) This most commonly happens when the request has already been parsed, or
processed in some other way. Since the input stream has aleady been consumed
by that earlier process, it is no longer available for parsing by Commons


My log file does show 2 threads processing the doPost event but I do not
know what I am doing to cause that.



Any idea, where I am going wrong?  





  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message