File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes NoClassDefFoundError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "NoClassDefFoundError" Watch "NoClassDefFoundError" New topic
Author

NoClassDefFoundError

H Kisna
Greenhorn

Joined: May 05, 2005
Posts: 5
SUBJECT: java.lang.NoClassDefFoundError

I am using Tomcat 4.1.31 on SuSE Linux 8.1 and Java 1.4

I have my application as following:

/local/tomcat/webapps/hari
/local/tomcat/webapps/hari/index.html
/local/tomcat/webapps/hari/WEB-INF/classes/util/BatchUpload1.class
/local/tomcat/webapps/hari/WEB-INF/classes/util/*.class
/local/tomcat/webapps/hari/WEB-INF/lib/cos.jar (this is Oreilly's predefined classes)
/local/tomcat/webapps/hari/WEB-INF/web.xml

I access my WEB application as http://us.hari.com/uhin/BatchUpload and get following error wonder why:
--------------------------------------------------------------------------------
description: The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Error instantiating servlet class util.BatchUpload1
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:865)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:621)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:163)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)

at java.lang.Thread.run(Thread.java:534)

root cause

java.lang.NoClassDefFoundError: com/oreilly/servlet/multipart/FileRenamePolicy

at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:1618)
at java.lang.Class.getConstructor0(Class.java:1930)
at java.lang.Class.newInstance0(Class.java:278)
at java.lang.Class.newInstance(Class.java:261)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:856)

-----------------------------------------------------------------------------------

I am using Oreilly's predefined classes which are stored in "cos.jar" file and under WEB-INF/lib/ directory... I have also added this to the CLASSPATH...


When I un-jar my cos.jar file I get follwing files...
com/oreilly/servlet/*.classes


Any pointer on this would be appreciated...

THANKS!

HARI OM
Sunetra Sen
Ranch Hand

Joined: Feb 17, 2005
Posts: 43
untar the cos.jar and check if the said file is present there.
I can see the file present in the correct folder structure in the cos.jar that I am using.
Sunetra Sen
Ranch Hand

Joined: Feb 17, 2005
Posts: 43
Originally posted by HARI KRSNA:
SUBJECT: java.lang.NoClassDefFoundError

I am using Tomcat 4.1.31 on SuSE Linux 8.1 and Java 1.4

I have my application as following:

/local/tomcat/webapps/hari
/local/tomcat/webapps/hari/index.html
/local/tomcat/webapps/hari/WEB-INF/classes/util/BatchUpload1.class
/local/tomcat/webapps/hari/WEB-INF/classes/util/*.class
/local/tomcat/webapps/hari/WEB-INF/lib/cos.jar (this is Oreilly's predefined classes)
/local/tomcat/webapps/hari/WEB-INF/web.xml

I access my WEB application as http://us.hari.com/uhin/BatchUpload and get following error wonder why:
--------------------------------------------------------------------------------
description: The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Error instantiating servlet class util.BatchUpload1
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:865)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:621)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:163)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)

at java.lang.Thread.run(Thread.java:534)

root cause

java.lang.NoClassDefFoundError: com/oreilly/servlet/multipart/FileRenamePolicy

at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:1618)
at java.lang.Class.getConstructor0(Class.java:1930)
at java.lang.Class.newInstance0(Class.java:278)
at java.lang.Class.newInstance(Class.java:261)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:856)

-----------------------------------------------------------------------------------

I am using Oreilly's predefined classes which are stored in "cos.jar" file and under WEB-INF/lib/ directory... I have also added this to the CLASSPATH...


When I un-jar my cos.jar file I get follwing files...
com/oreilly/servlet/*.classes


Any pointer on this would be appreciated...

THANKS!

HARI OM



If you have added the jar to the applications WEB-INF/lib folder then there is no need to put it in the class path seperately.Every jar in the application's lib folder should be available for the servlet when running in the tomcat's servlet container.
H Kisna
Greenhorn

Joined: May 05, 2005
Posts: 5
THANKS Senetra.

I unjared my cos.jar file and found the file FileRenamePolicy.class in the directory...

Any other hints? Also, do I have to unjar my cos.jar file under my WEB-INF/classes or is it ok to have it as cos.jar?

THANKS!

HARI OM
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

"HARI KRSNA",

There aren't may rules that have been put into place here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
H Kisna
Greenhorn

Joined: May 05, 2005
Posts: 5
Thanks Bear... I changed my Name... that is my actaul name...

Any hints on my Error...?
Sunetra Sen
Ranch Hand

Joined: Feb 17, 2005
Posts: 43
You should not need to unjar the cos.jar in the lib/classes folder.
But if the cos.jar has the class then I am not sure what the problem is?
Try putting the cos.jar in the tomcat's common/lib folder and see. :roll:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NoClassDefFoundError