This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes IDEs, Version Control and other tools and the fly likes NoClassDefFound error when using Commons File Upload library Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "NoClassDefFound error when using Commons File Upload library" Watch "NoClassDefFound error when using Commons File Upload library" New topic
Author

NoClassDefFound error when using Commons File Upload library

Paul Featherstone
Greenhorn

Joined: Mar 22, 2011
Posts: 6
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

Joined: Sep 24, 2009
Posts: 77


You need to put Commons-IO jar as well. Fileupload jar has a dependency on it.


Thanks and Regards, Souvik
SCJP, SCWCD, OCEJWSD
Paul Featherstone
Greenhorn

Joined: Mar 22, 2011
Posts: 6
Thanks Souvic, this worked..hurray!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: NoClassDefFound error when using Commons File Upload library
 
Similar Threads
problem with tomcat embedded application
Eclipse not seeing updated JAR in tomcat\lib library at runtime
Tomcat 6.0 and Axis 1.4 XML Security Error
Trouble setting up Hibernate with Struts in Eclipse
Eclipse: Can't add new package