File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping 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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "NoClassDefFoundError" Watch "NoClassDefFoundError" New topic


Sunder Ganapathy
Ranch Hand

Joined: Apr 01, 2003
Posts: 120
I get the above message while using logging in a Hibernate program.

The message is java.lang.NoClassDefFoundError: Could not initialize class

I have all the jar files, namely, ejb3-persistence, hibernate3, hibernate.cfg,
hibernate-annotations, hibernate-commons-annotations, hibernate-entitymanager and hibernate-validator in both classpath and Tomcat lib file.
What could be the reason.
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

Classloaders are a mysterious thing.

Which class is using the class that can't be found. Package the jar along with that class, not just on the JVM or Tomcats classpath. Various components have different classloaders and this can trigger just these types of problems.

-Cameron McKenzie
Sunder Ganapathy
Ranch Hand

Joined: Apr 01, 2003
Posts: 120
Thanks Cameron.

When I came to know that validating can also be done using Hibernate,
I started using the same "C:\_hiblib" for this also. I was using Log4j also
in my program . In one of the JBOSS forums, I read that duplicate declarations
cause problems . Now the issue is resolved.
I agree. Here's the link:
subject: NoClassDefFoundError
It's not a secret anymore!