aspose file tools*
The moose likes Servlets and the fly likes Servlet throws unnamed exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet throws unnamed exception" Watch "Servlet throws unnamed exception" New topic
Author

Servlet throws unnamed exception

John Frink
Greenhorn

Joined: Apr 13, 2012
Posts: 2

Hello everyone,
I have a servlet that utilizes Apache Commons FileUpload. I have had much success with this library in other applications but I'm getting an unknown error now that won't go away.

There is a simple HTML page that contains a form with one field.
But when the servlet is called the process errors out when calling the method parseRequest().
The error message is as follows...
StandardWrapperValve[DataUploadManager]: PWC1406: Servlet.service() for servlet DataUploadManager threw exception
at gov.usdoj.deadiversion.utl.DataUploadManager.doPost(DataUploadManager.java:133)


How come it doesn't state which exception?
The line it points to is...
fileItems = upload.parseRequest(req);
I have a catch block for the FileUploadException however it never executes... flow just falls thru to the finally block.

How does one go about determining the exception when the stack trace doesn't list it?

Piyush Mangal
Ranch Hand

Joined: Jan 22, 2007
Posts: 196



In your code, finally will always run irrespective of whether exception occurs or not. See if it might be the issue.
Dhaval J. Patel
Ranch Hand

Joined: Mar 10, 2011
Posts: 90

If it does not go into the catch block and goes directly into the finally block, means that the exception is occuring inside the parseRequest method but the underlying code does not "throw" this exception. Instead the exception has been caught by the code inside the implementation of parseRequest method and the message you see probably is coming from the catch block in that code.

I have a feeling that you found a glitch in the api you are using. You should download the source code of the commons fileupload api that you are using and surf through the code to see where the exception might be occurring. I dont know why the api did not give some kind of detailed information in their catch block, normally there is a stacktrace attached.

I am really not sure. But if that is the case then there is no way of determining the name of the exception or possibly printing a stack trace unless you look into the source code of the api and look where the exception is occuring by dropping a few print lines inside catch blocks of the source code. Follow the parseRequest method. I just looked it up. The implementation of the method is in the FileUploadBase.java file, if you wanna look into the apache commons file upload api source code.

If you find out for sure that it is a glitch in the api then the best thing to do would be to report it.

I am just curios. Is there a specific case when this error occurs ? or is it just an exception that occurs but does not disrupt the normal flow of your program ? Does it fail your program ?
Vanessa Danin
Ranch Hand

Joined: Oct 04, 2004
Posts: 34
John, two things that come to mind are that either the exception is not being thrown where you think it is (e.g. which is the DataUploadManager servlet?) or it is not a FileUploadException that is being thrown. If you are not able to catch the exception, perhaps start by defining a catch block for the Exception class, instead of for a specific Exception class (e.g. FileUploadException) and then try print out the class name of the Exception (e.g. using the Exception toString method) in that catch block. I hope this helps point you in the right direction.

John Frink
Greenhorn

Joined: Apr 13, 2012
Posts: 2

Dhaval, the strange thing is that I have another upload web application that uses this same library and it works just fine. In fact I copied much of that code to build this one.

Thanks for the insight. I should be able to make some headway today. I think I will start with Vanessa's idea and see if I can get a name for this exception. Then I will delve into the FileUploadBase class and build a catch block that traps all of its related exceptions.

Thanks again - john

I'm also removing that finally block since I'm using it incorrectly anyway.
 
wood burning stoves
 
subject: Servlet throws unnamed exception