Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Class not found error from deployed servlet

 
Fabio Piergentili
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Fabio Piergentili
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the info but their is not other classes of the same name. Still searching....
 
Michael Kelly
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 650
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic