Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ExceptionInInitializerError NoClassDefFoundError

 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like you need ehcache.jar.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 293
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We are using Hibernate 3 and EJB 3.0

Thanks

Mark
 
Nick Heudecker
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic