java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()Z

java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()Z 转载▼

在hibernate3.5的时候
出现如下错误:

01.java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()Z
02.    at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1837)
03.    at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:769)
04.    at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:733)
05.    at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:636)
06.    at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:359)
07.    at org.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:838)
08.    at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:128)
09.    at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:91)
10.    at Test.HibernateORMappingTest.testSchemaExport(HibernateORMappingTest.java:32)
11.    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
12.    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
13.    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
14.    at java.lang.reflect.Method.invoke(Unknown Source)
15.    at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
16.    at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
17.    at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
18.    at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
19.    at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
20.    at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
21.    at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
22.    at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
23.    at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
24.    at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
25.    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
26.    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
27.    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
28.    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
29.    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
30.    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

使用MyEclipse创建JavaEE5.0的Web项目,在使用Hibernate3.5.1的注解功能时出现错误:
java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()Z 。
解决办法:删除对Java EE 5 Libraries中的persistence.jar的使用。
问题原因:javaee.jar中的persistence.jar部分类与hibernate-jpa-2.0-api-1.0.0.Final.jar存在版本冲突

你可能感兴趣的:(Web,javaee,JUnit)