Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

org.apache.commons.fileupload.FileUploadException

 
sam wootton
Ranch Hand
Posts: 94
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20768
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 94
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 94
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20768
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 94
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 94
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 94
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I AM AN IDIOT.

I had my lib dir in <webapp>/lib

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

Regards, Sam
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic