-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: NoClassDefFoundError: org/hibernate/cfg/Configuration
PostPosted: Tue Nov 16, 2010 9:45 am 
Beginner
Beginner

Joined: Mon Nov 15, 2010 10:39 am
Posts: 27
Hi.

I am getting this error message when trying to load a Configuration:

Exception in thread "main" java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
Caused by: java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)

I have added the path to the hibernate .jar file in classpath:
[...]/.m2/repository/org/hibernate/hibernate/3.6.0


Top
 Profile  
 
 Post subject: Re: NoClassDefFoundError: org/hibernate/cfg/Configuration
PostPosted: Tue Nov 16, 2010 10:26 am 
Beginner
Beginner

Joined: Fri Aug 24, 2007 4:46 am
Posts: 36
Location: Bielefeld / Germany
Seems that hibernate.jar isn't available on your classpath. Can you provide more details about your setup?

Cheers, Maik

_________________
jease.org - Java with Ease


Top
 Profile  
 
 Post subject: Re: NoClassDefFoundError: org/hibernate/cfg/Configuration
PostPosted: Tue Nov 16, 2010 10:56 am 
Beginner
Beginner

Joined: Mon Nov 15, 2010 10:39 am
Posts: 27
Ok,

I am using maven, and had some trouble getting hibernate through dependencies, so added the 3.6.0 release manually. The hibernate3.jar file was copied by maven into .../.m2/repository/org/hibernate/hibernate/3.6.0, and renamed hibernate-3.6.0.jar (as far as i can tell, same size and what looks to be same content).

I then added a dependency to hibernate in maven, like this:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.6.0</version>
</dependency>

This compiles without errors with mvn install.

Then, when i try to run using java -jar on the resulting jar file, i get the above mentioned error message. I have tried adding both the .m2/repository/org/hibernate/hibernate/3.6.0, and the path where the hibernate3.jar file resides to my CLASSPATH, with the same result..

Do i need any other jar files in the classpath, besides the core hibernate jar?


Top
 Profile  
 
 Post subject: Re: NoClassDefFoundError: org/hibernate/cfg/Configuration
PostPosted: Tue Nov 16, 2010 11:07 am 
Beginner
Beginner

Joined: Fri Aug 24, 2007 4:46 am
Posts: 36
Location: Bielefeld / Germany
Yes, you'll need all jars from hibernate-distribution/lib/required on your classpath:

antlr-2.7.6.jar
commons-collections-3.1.jar
dom4j-1.6.1.jar
javassist-3.12.0.GA.jar
jta-1.1.jar
slf4j-api-1.6.1.jar

Have a look at the starter guide:

http://docs.jboss.org/hibernate/core/3.6/quickstart/en-US/html_single/#hibernate-gsg-setup-releaseBundle

Cheers, Maik

_________________
jease.org - Java with Ease


Top
 Profile  
 
 Post subject: Re: NoClassDefFoundError: org/hibernate/cfg/Configuration
PostPosted: Tue Nov 16, 2010 11:09 am 
Beginner
Beginner

Joined: Mon Nov 15, 2010 10:39 am
Posts: 27
Ok, thanks, will try that.

Quick question about classpath, does it work through folders, or do i need the exact folder where the file is? (since i'm using maven it would be a lot easier to just add .m2/repository to classpath..)

Added /hibernate-distribution-3.6.0.Final/lib/required and /hibernate-distribution-3.6.0.Final to the classpath, still not luck..

Edit: Having a real hard time understanding this, and googleling doesn't really help, since 90% of the things i find are old things that have been changed *sigh*..

Since i am using maven, the maven dependency way should be the easiest way to go.

The quick start guide you linked to tells me to use org.hibernate.hibernate-core. I check in the maven repository browser which version of hibernate-core should be available, and try some of these, but maven can't find them. So i'll try org.hibernate.hibernate, version 3.2.4.ga, which maven can find.

With the added dependency in maven, i shouldn't have to do anything else to get this to work?

Also, my resulting .jar file does not contain anything other than my compiled source files. Is this correct? Combined with setting the $CLASSPATH env variable to the locations of the hibernate jars (corresponding to the maven dependency), this should work?

I have also added the jar files to the project library in eclipse, dunno if this is needed..


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.