Blue Blue - 1 year ago 318
Java Question

java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration

I'm trying to do an initial setup with Hibernate in Eclipse, while deploying with Tomcat.

I encountered the following problem:

java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration

I've goggled my problem online and I understand that it has something to to with the project class path.

I've added a user library to my project containing all the jars under the "required" directory in the hibernate download, but that doesn't seem to work.

Please find a screen shot of my project here:

Answer Source

You're getting the error because the hibernate libraries are not available to Tomcat. In your picture, below the hibernate library set there is an empty set called 'Web App Libraries' - this is the set your hibernate libraries need to be in.

Right click your project -> Build Path -> Configure Build Path, and remove the hibernate set from the build path. Now import the jars into the WEB-INF/lib folder. Refresh your project and now you should see them listed in the 'Web App Libraries' set (i appreciate this is somewhat annoying that you have to import them into your code base - someone else might know a better way to do this that doesn't involve copying the jars in)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download