aspose file tools*
The moose likes Object Relational Mapping and the fly likes ExceptionInInitializerError NoClassDefFoundError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "ExceptionInInitializerError NoClassDefFoundError" Watch "ExceptionInInitializerError NoClassDefFoundError" New topic
Author

ExceptionInInitializerError NoClassDefFoundError

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

In the infamouse HibernateUtil class there is this code



I am getting the NoClassDefFoundError, and not sure why or how to correct it. I am assuming it is simply a file and/or jar that I need in my classpath but not sure what it is. Any help?

I have all the required jar files listed from the _README.txt in the hibernate lib directory.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

OK this might be a clue.

Caused by: java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException

Just saw it as I clicked Add Post.



Mark
Nick Heudecker
Ranch Hand

Joined: Jul 09, 2000
Posts: 52
Looks like you need ehcache.jar.


---<br />Co-author of "Hibernate Quickly"<br /><a href="http://www.manning.com/books/peak" target="_blank" rel="nofollow">http://www.manning.com/books/peak</a>
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

I thought that too, and I have it already in my client and I added it to the Hibernate.deployer in JBoss, but still getting the same error.

Mark
Dave Salter
Ranch Hand

Joined: Jul 20, 2005
Posts: 293

Hibernate needs quite a few jars from its distribution directory. Which ones are you using?

Are you using Hibernate 3 or Hibernate 2?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

We are using Hibernate 3 and EJB 3.0

Thanks

Mark
Nick Heudecker
Ranch Hand

Joined: Jul 09, 2000
Posts: 52
Mark:

Have you set your logging to DEBUG? Remember that you'll need to update your log4j.properties file to reflect the new package name.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Originally posted by Nick Heudecker:
Mark:

Have you set your logging to DEBUG? Remember that you'll need to update your log4j.properties file to reflect the new package name.


Hmm, that's an interesting response. I am not sure what the logging is set, as the Hibernate files and config files are from another developer that can run his unit tests outside the container fine. It is when I run it in the App Server that we have this problem.

Does setting the logging level change the classpath, or need more in the classpath that not changing the logging level?

Thanks

Mark
Lars Vonk
Ranch Hand

Joined: Aug 05, 2005
Posts: 30
Hello Mark,

Does setting the logging level change the classpath, or need more in the classpath that not changing the logging level?

I am not sure if I understand your question correctly but you don't have to change your classpath if you change your logging level using log4j.

Maybe you can check the dependencies for the ehcache.jar:
According to the ehcache docs you need commons-logging when using jdk1.4.
If you are using jdk1.3 you need commons-collections, version 2.1 and Apache xerces (xml-apis.jar and xercesImpl.jar), version 2.5.
I know these jars are all marked are required in the _README.txt but maybe its worth double checking.

Lars
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Thanks Lars. Actually we are using JDK 1.5 Lucky us. Man it is a dream to code with.

I am thinking that I might have placed jars in the wrong directory or something in JBoss directories. I placed the cache jar into the hibernate.deployer directory and maybe it belongs in the lib directory instead.

Mark
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Yep that was it, I just put the jar file into the wrong directory. But now I don't even need it in my JBoss when my manager said to stop using EJBs and have the Client use Hibernate to talk to the database directly.

Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ExceptionInInitializerError NoClassDefFoundError