wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes org.apache.commons.fileupload.FileUploadException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "org.apache.commons.fileupload.FileUploadException" Watch "org.apache.commons.fileupload.FileUploadException" New topic
Author

org.apache.commons.fileupload.FileUploadException

sam wootton
Ranch Hand

Joined: Apr 16, 2011
Posts: 68
    
    1
Hi,

Thanks in advance for any help.

I am getting the following error when I hit my servlet:



However, in my servlet lib dir I have:



I have no compilation errors. As far as I was aware (and has always been the case), that specific exception is in the listed jar above, I downloaded from

http://commons.apache.org/proper/commons-fileupload/download_fileupload.cgi

Regards, Sam
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

So you have two copies of the commons-fileupload jar, which are different versions? The incompatible classes in those two jars are likely the source of your problem. Get rid of one of them and make sure you compile against the one you decided to keep.
sam wootton
Ranch Hand

Joined: Apr 16, 2011
Posts: 68
    
    1
Paul Clapham,

Many thanks, seems to have fixed my problem.

I assumed (stupidly I guess) that having two, wouldn't mean none were found. But I guess a conflict would mean neither was used.

Thanks.

Regards, Sam
sam wootton
Ranch Hand

Joined: Apr 16, 2011
Posts: 68
    
    1
Apologies, I spoke too soon.

I am still getting:

I compile against

/commons-fileupload-1.3/lib/commons-fileupload-1.3.jar

And I have this in my webapp lib:

Could commons-io-2.1.jar be conflicting with commons-fileupload-1.3.jar?

I am experiencing the same problem with jdbc, where I compile & have in my lib:

But still get:


I no longer have any duplicate versions of the same jars, but seem to be getting the above errors.

Any help appreciated.

Regards, Sam
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

NoClassDefFoundError always means the class isn't in the classpath. So presumably the "lib" folder you're looking at isn't the one which is actually in the application's classpath when it's running.
sam wootton
Ranch Hand

Joined: Apr 16, 2011
Posts: 68
    
    1
H Paul Clapham,

Thanks for your help.

I only have 1 Servlet I have deployed (others are inbuilt tomcat example servlets).

So I have a single webapp with this structure:

In which is

Perhaps I should try putting them in


... as this is the priority in the lib hierarchy? Either way, I am certain I am pointing to the correct (only) lib dir.

Regards, Sam
sam wootton
Ranch Hand

Joined: Apr 16, 2011
Posts: 68
    
    1
I played around with a few jars and moved them in to tomcat/lib

This seems to resolve those errors, and now I could just continue copying the rest (as I have now moved on to the next missing jar error).

But it seems to me that tomcat isn't looking in my <webapp>/lib dir, but stopping at tomcat/lib.

Any ideas? I'm not aware that I previously set any var/setting to configure tomcats preferred lib dir?

http://stackoverflow.com/questions/5474765/order-of-loading-jar-files-from-lib-directory

Summarized, the loading order is as follows:

bootstrap/system (JRE/lib, then server.loader)
webapp libraries (WEB-INF/classes, then WEB-INF/lib)
common libraries (common.loader, then Tomcat/lib)
webapp-shared libraries (shared.loader)

Regards, Sam
sam wootton
Ranch Hand

Joined: Apr 16, 2011
Posts: 68
    
    1
I AM AN IDIOT.

I had my lib dir in <webapp>/lib

Moved it to <webapp>/WEB-INF/lib

Regards, Sam
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: org.apache.commons.fileupload.FileUploadException