Hibernate使用过程碰到的一些问题小结
来源:互联网 发布:vector magic 1.15软件 编辑:程序博客网 时间:2024/05/20 21:23
Hibernate 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:1355) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1826) at StudentTest.main(StudentTest.java:16) Caused by: java.lang.ClassNotFoundException: javax.persistence.EntityListeners at 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
解决方法:
添加
ejb3-persistence.jar
Exception in thread "main" org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/test/model/Student.hbm.xml
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:3951)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXmlQueue(Configuration.java:3940)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3928)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1368)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1826)
at StudentTest.main(StudentTest.java:16)
Caused by: org.hibernate.MappingException: class com.test.model.Student.Student not found while looking for property: id
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:232)
at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:316)
at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:451)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:384)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:323)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:174)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:3948)
... 5 more
Caused by: java.lang.ClassNotFoundException: com.test.model.Student.Student
at 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)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192)
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:228)
... 11 more
解决方法:
将Student.hbm.xml中的
<class name="Student" table="student">
改为
<class name="com.test.model.Student" table="student">
Exception in thread "main" java.lang.NoClassDefFoundError: javax/persistence/Cacheable
at org.hibernate.cfg.AnnotationBinder.determineCacheSettings(AnnotationBinder.java:988)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:579)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3977)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3931)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1368)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1826)
at TeacherTest.main(TeacherTest.java:17)
Caused by: java.lang.ClassNotFoundException: javax.persistence.Cacheable
at 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)
... 7 more
加包
hibernate-distribution-3.6.0.Final/lib/jpa/hibernate-jpa-2.0-api-1.0.0.Final.jar
- Hibernate使用过程碰到的一些问题小结
- 使用Hibernate Validator中碰到的一些问题
- Aurora一些使用过程中碰到的问题
- hibernate初学者可能碰到的一些问题
- hibernate初学者可能碰到的一些问题
- JBPM4 使用中碰到的一些问题
- ionic使用中碰到的一些问题
- 使用myfaces过程中碰到的问题
- Loadrunner使用过程中碰到的问题
- Selenium使用过程中碰到的问题
- Odps使用过程中碰到的问题。
- AndroidStudio使用过程中碰到的问题
- ununtu 12.04 LTS 使用过程的一些问题小结
- VS2010编译以及使用GLUI过程中碰到的一些问题
- 使用Retrofit过程中碰到的一些问题(持续更新。。。。)
- 使用hibernate经常碰到的一些异常介绍
- 使用hibernate经常碰到的一些异常介绍
- 看代码过程中碰到的一些问题以及笔记
- Java 5 新特性——增强for循环
- ggjj
- 良好的心态
- Math的用法--------------随机,静态方法
- DECODE的语法
- Hibernate使用过程碰到的一些问题小结
- Mahara安装
- android 监听网络连接
- Linux下tar bz gz等压缩包的压缩和解压
- Osiris
- 生成迷宫算法
- eclipse PDT中xdebug调试问题
- oracle中判断表是否存在,进行处理
- Memcached 集群架构问题归纳