Document directory
- Environment
- Problem
- Solution
- References
Environment
MySQL 5.1 + hibernate 3.2 + myeclipse 8.6
Problem
When you use hibernate to insert data, the following exception is reported:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".SLF4J: Defaulting to no-operation (NOP) logger implementationSLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.Exception in thread "main" java.lang.NoClassDefFoundError: javax/persistence/EntityListenersat 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:1385)at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1856)at com.oracle.entities.Test.main(Test.java:53)Caused by: java.lang.ClassNotFoundException: javax.persistence.EntityListenersat java.net.URLClassLoader$1.run(URLClassLoader.java:200)at java.security.AccessController.doPrivileged(Native Method)at java.net.URLClassLoader.findClass(URLClassLoader.java:188)at java.lang.ClassLoader.loadClass(ClassLoader.java:307)at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)at java.lang.ClassLoader.loadClass(ClassLoader.java:252)at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)... 5 more
Solution
Hibernate requires JPA support, import JPA jar package (hibernate-jpa-2.0-api-1.0.1.Final.jar.
References
Http://javapub.iteye.com/blog/869380
|
|
| @ Wentasy blog is for your reference only. Welcome to visit. I hope to criticize and correct any mistakes. If you need to repost the original blog post, please indicate the source. Thank you for the [csdn blog] |