Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NoClassDefFound error when using Commons File Upload library

 
Paul Featherstone
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have developed a simple file upload servlet in Eclipse, all works fine using test version of a Java EE web project running Tomcat V7.

When I have switched to my non testing version project using Tomcat v6 (it needs to be this v as specified in project requirements) the script will not run. After hours looking at this I have found the following:

1) The Commons File Upload library was not saved as part of the v7 project - I have now added this to the build path saved within the Tomcat 6 folder (should this in-fact be saved in WEB-INF/lib or does this not really matter?)
2) Eclipse is prompting me to point to the tomcat-coyote.jar file in my Tomcat V7 folder
3) Following the above fix from Eclipse causes a java.lang.NoClassDefFoundError - this makes sense as I clearly don't want to be using two sets of files for V6/V7

The odd thing is that out of the following class imports:



The first two are fine but the second two cause issues.

It seems that compiling on v7 and switching to v6 to execute has caused these issues, is it that DiskFileItemFactory and ServletFileUpload in the Commons File Upload library are not supported on Tomcat v6 or is there another explanation?

Any pointers would be much appreciated, thanks in advance!

Regards,
Paul

 
Souvik Dasgupta
Ranch Hand
Posts: 95
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You need to put Commons-IO jar as well. Fileupload jar has a dependency on it.
 
Paul Featherstone
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Souvic, this worked..hurray!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic