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 Class not found error from deployed servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Class not found error from deployed servlet" Watch "Class not found error from deployed servlet" New topic
Author

Class not found error from deployed servlet

Fabio Piergentili
Ranch Hand

Joined: Sep 04, 2009
Posts: 57
I am getting a

java.lang.NoClassDefFoundError: Could not initialize class com.landry.core.sql.QueryBuilder

from my serlvet. I verified that the class exists in the servlet/WEB-INF/class directory in the correct path of the package specified.

Does anyone know of any other reason tomcat would give this error?

Thanks
Fabio
Mazer Lao Tzu
Ranch Hand

Joined: Jan 20, 2010
Posts: 35
I have seen Tomcat give this error when two jars with the same class are loaded.
Check that you are not loading two different versions of the same jar file or the same jar file from two different places.



-- Mazer
Fabio Piergentili
Ranch Hand

Joined: Sep 04, 2009
Posts: 57
Thanks for the info but their is not other classes of the same name. Still searching....
Michael Kelly
Greenhorn

Joined: Apr 05, 2009
Posts: 6
"Could not initialize class" (I think) means that it found the class but something went wrong loading/constructing it.

I would attach a debugger to Tomcat and take a look what goes on before this class is loaded.
Fabio Piergentili
Ranch Hand

Joined: Sep 04, 2009
Posts: 57
I tried by turning on

<Valve className="org.apache.catalina.valves.RequestDumperValve"/>

in server.xml file but no detailed info before problem object creation.

Do you have another debugging method in mind....

Thanks
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 643
Fabio Piergentili wrote:I am getting a

java.lang.NoClassDefFoundError: Could not initialize class com.landry.core.sql.QueryBuilder

from my serlvet. I verified that the class exists in the servlet/WEB-INF/class directory in the correct path of the package specified.

Does anyone know of any other reason tomcat would give this error?

Thanks
Fabio


This was probably just a typo, but can you please verify that you placed the classes in the WEB-INF/classes directory, not WEB-INF/class?
Fabio Piergentili
Ranch Hand

Joined: Sep 04, 2009
Posts: 57
I found it.

The class it was complaining about was using a class ( log4j logger ) that needed to be in the lib directory of the tomcat server. I had to copy the library log4j.jar to that directory.

Very bad error. It totally threw me. I wonder why it did not complain about the class that was actually missing? Anyway, thanks for the help and if you have info on how to debug tomcat that would be helpful in future problems as I can see what is actually being called.

Thanks Again
Michael Kelly
Greenhorn

Joined: Apr 05, 2009
Posts: 6
Glad to hear you found the problem.

Here's an article that explains how to setup debugging in Tomcat + a bunch of other servers.

http://www.eclipsezone.com/eclipse/forums/t53459.html
Fabio Piergentili
Ranch Hand

Joined: Sep 04, 2009
Posts: 57
Mark E Hansen wrote:This was probably just a typo, but can you please verify that you placed the classes in the WEB-INF/classes directory, not WEB-INF/class?


It was a typo I did put it in WEB-INF/classes
 
wood burning stoves
 
subject: Class not found error from deployed servlet