-->
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.  [ 4 posts ] 
Author Message
 Post subject: java.lang.NoClassDefFoundError: javax/persistence/EntityList
PostPosted: Tue Oct 12, 2010 3:49 am 
Newbie

Joined: Tue Oct 12, 2010 3:38 am
Posts: 1
Hi All,

I have just started learning Hibernate. And following tutorial @ http://www.vaannila.com/hibernate/hiber ... ols-1.html. And have included following jars as user libraries in project:-
antlr-2.7.6.jar,commons-collections-3.1.jar,dom4j-1.6.1.jar,hibernate3.jar,javassist-3.12.0.GA.jar,jta-1.1.jar,log4j-1.2.8.jar,mysql-connector-java-5.1.13-bin.jar,slf4j-api-1.6.1.jar,slf4j-simple-1.6.1.jar.

But when I am running the Main program I am getting following error in console:-

Code:
312 [main] INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.2.0.Final
344 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.6.0.CR2
344 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
344 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
375 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
547 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
969 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
4266 [main] WARN org.hibernate.util.DTDEntityResolver - recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
4437 [main] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : com/vaannila/course/Course.hbm.xml
6828 [main] WARN org.hibernate.util.DTDEntityResolver - recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
7015 [main] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
Exception in thread "main" java.lang.NoClassDefFoundError: javax/persistence/EntityListeners
   at org.hibernate.cfg.annotations.reflection.JPAMetadataProvider.getDefaults(JPAMetadataProvider.java:96)
   at org.hibernate.annotations.common.reflection.java.JavaReflectionManager.getDefaults(JavaReflectionManager.java:226)
   at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1353)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1824)
   at com.vaannila.util.HibernateUtil.<clinit>(HibernateUtil.java:10)
   at com.vaannila.course.Main.saveCourse(Main.java:26)
   at com.vaannila.course.Main.main(Main.java:15)
Caused by: java.lang.ClassNotFoundException: javax.persistence.EntityListeners
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   ... 7 more


Request you all to please help in solveing the above error.


Top
 Profile  
 
 Post subject: Re: java.lang.NoClassDefFoundError: javax/persistence/EntityList
PostPosted: Tue Oct 19, 2010 2:44 pm 
Newbie

Joined: Wed Nov 04, 2009 4:00 pm
Posts: 3
Notice this line in your output: "7015 [main] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null". Also look at the stack trace where it shows code in your program (vs. Hibernate code):
at com.vaannila.util.HibernateUtil.<clinit>(HibernateUtil.java:10)
at com.vaannila.course.Main.saveCourse(Main.java:26)
at com.vaannila.course.Main.main(Main.java:15)

HibernateUtil, line 10 is:
sessionFactory = new Configuration().configure().buildSessionFactory();

It looks like HIbernate can't find your configuration file (hibernate.cfg.xml?) which "is by default expected to be in the root of your CLASSPATH." (see Hibernate Core Reference).

Check your classpath and the location of your configuration file and make sure it matches what the tutorial told you to do.

Good Luck!


Top
 Profile  
 
 Post subject: Re: java.lang.NoClassDefFoundError: javax/persistence/EntityList
PostPosted: Tue Oct 19, 2010 3:24 pm 
Newbie

Joined: Wed Nov 04, 2009 4:00 pm
Posts: 3
OK, I just noticed that you double-posted this at Java Ranch and got an answer there. Please don't double post. I wasted a least a half hour trying to figure this out for you. 8-(

This seems to be caused by Hibernate 3.6. It is now dependent on JPA, so it must have a JPA jar in the class path as well. You can find one in the Hibernate 3.6 distro: hibernate-distribution-3.6.0.Final/lib/jpa/hibernate-jpa-2.0-api-1.0.0.Final.jar


Top
 Profile  
 
 Post subject: Re: java.lang.NoClassDefFoundError: javax/persistence/EntityList
PostPosted: Sat Mar 19, 2011 1:11 pm 
Newbie

Joined: Sat Mar 19, 2011 1:01 pm
Posts: 1
@ajhampson: That's great info for me, thanks for still posting about the JPA! If it's of any help to others just getting started with the tutorial, I also needed the H2 jar from here to get the 'NativeApiIllustrationTest' JUnit test to run successfully.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.