本文介绍了java.lang.NoSuchMethodError:javax.persistence.OneToMany.orphanRemoval()Z的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我收到此错误:java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()Z这些是我的类路径中的jar:These are the jars in my classpath:com.sun.faces/jsf-api/jars/jsf-api-2.0.0.jarcom.sun.faces/jsf-impl/jars/jsf-impl-2.0.0.jarorg.apache.myfaces.orchestra/myfaces-orchestra-core20/jars/myfaces-orchestra-core20-1.5-SNAPSHOT.jarcommons-lang/commons-lang/jars/commons-lang-2.1.jarcommons-logging/commons-logging/jars/commons-logging-1.1.1.jarorg.springframework/spring/jars/spring-2.5.6.jarcommons-el/commons-el/jars/commons-el-1.0.jarorg.richfaces.ui/richfaces-ui/jars/richfaces-ui-3.3.3.Final.jarorg.richfaces.framework/richfaces-api/jars/richfaces-api-3.3.3.Final.jarcommons-collections/commons-collections/jars/commons-collections-3.2.jarcommons-beanutils/commons-beanutils/jars/commons-beanutils-1.8.0.jarorg.richfaces.framework/richfaces-impl-jsf2/jars/richfaces-impl-jsf2-3.3.3.Final.jarcom.sun.facelets/jsf-facelets/jars/jsf-facelets-1.1.14.jarorg.hibernate/hibernate-core/jars/hibernate-core-3.6.0.Final.jarantlr/antlr/jars/antlr-2.7.6.jardom4j/dom4j/jars/dom4j-1.6.1.jarorg.hibernate/hibernate-commons-annotations/jars/hibernate-commons-annotations-3.2.0.Final.jarorg.slf4j/slf4j-api/jars/slf4j-api-1.6.1.jarorg.hibernate.javax.persistence/hibernate-jpa-2.0-api/jars/hibernate-jpa-2.0-api-1.0.0.Final.jarjavax.transaction/jta/jars/jta-1.1.jarorg.hibernate/hibernate-c3p0/jars/hibernate-c3p0-3.6.0.Final.jarc3p0/c3p0/jars/c3p0-0.9.1.jarorg.hibernate/hibernate-entitymanager/jars/hibernate-entitymanager-3.6.0.Final.jarcglib/cglib/jars/cglib-2.2.jarasm/asm/jars/asm-3.1.jarjavassist/javassist/jars/javassist-3.12.0.GA.jarorg.hibernate/hibernate-search/jars/hibernate-search-3.3.0.Final.jarorg.hibernate/hibernate-search-analyzers/jars/hibernate-search-analyzers-3.3.0.Final.jarorg.apache.lucene/lucene-core/jars/lucene-core-3.0.3.jarorg.apache.lucene/lucene-analyzers/jars/lucene-analyzers-3.0.3.jarmysql/mysql-connector-java/jars/mysql-connector-java-5.1.13.jarcom.ocpsoft/prettyfaces-jsf2/jars/prettyfaces-jsf2-3.0.1.jarcommons-digester/commons-digester/jars/commons-digester-2.0.jarorg.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.6.1.jarlog4j/log4j/bundles/log4j-1.2.16.jarxom/xom/jars/xom-1.2.5.jarxml-apis/xml-apis/jars/xml-apis-1.3.03.jarxerces/xercesImpl/jars/xercesImpl-2.8.0.jarxalan/xalan/jars/xalan-2.7.0.jarorg.jboss.jsfunit/jboss-jsfunit-core/jars/jboss-jsfunit-core-1.3.0.Final.jarnet.sourceforge.htmlunit/htmlunit/jars/htmlunit-2.8.jarxalan/xalan/jars/xalan-2.7.1.jarxalan/serializer/jars/serializer-2.7.1.jarxml-apis/xml-apis/jars/xml-apis-1.3.04.jarcommons-collections/commons-collections/jars/commons-collections-3.2.1.jarcommons-lang/commons-lang/jars/commons-lang-2.4.jarorg.apache.httpcomponents/httpclient/jars/httpclient-4.0.1.jarorg.apache.httpcomponents/httpcore/jars/httpcore-4.0.1.jarcommons-codec/commons-codec/jars/commons-codec-1.4.jarorg.apache.httpcomponents/httpmime/jars/httpmime-4.0.1.jarorg.apache.james/apache-mime4j/jars/apache-mime4j-0.6.jarnet.sourceforge.htmlunit/htmlunit-core-js/jars/htmlunit-core-js-2.8.jarxerces/xercesImpl/jars/xercesImpl-2.9.1.jarnet.sourceforge.nekohtml/nekohtml/jars/nekohtml-1.9.14.jarnet.sourceforge.cssparser/cssparser/jars/cssparser-0.9.5.jarorg.w3c.css/sac/jars/sac-1.3.jarcommons-io/commons-io/jars/commons-io-1.4.jarcactus/cactus/jars/cactus-13-1.7.1.jarcactus/cactus-ant/jars/cactus-ant-13-1.7.1.jarcommons-httpclient/commons-httpclient/jars/commons-httpclient-2.0.2.jarjunit/junit/jars/junit-3.8.1.jaraspectj/aspectjrt/jars/aspectjrt-1.2.1.jarcargo/cargo/jars/cargo-0.5.jarant/ant/jars/ant-1.5.4.jar这是我的ivy.xml:and this is my ivy.xml:<dependencies> <!-- JSF 2.0 RI --> <dependency org="com.sun.faces" name="jsf-api" rev="2.0.0"/> <dependency org="com.sun.faces" name="jsf-impl" rev="2.0.0"/> <!-- MyFaces Orchestra --> <dependency org="org.apache.myfaces.orchestra" name="myfaces-orchestra-core20" rev="1.5-SNAPSHOT"/> <dependency org="org.springframework" name="spring" rev="2.5.6"/> <dependency org="commons-el" name="commons-el" rev="1.0"/> <!-- RichFaces --> <dependency org="org.richfaces.ui" name="richfaces-ui" rev="3.3.3.Final"/> <dependency org="org.richfaces.framework" name="richfaces-impl-jsf2" rev="3.3.3.Final"/> <dependency org="com.sun.facelets" name="jsf-facelets" rev="1.1.14"/> <!-- Hibernate --> <dependency org="org.hibernate" name="hibernate-core" rev="3.6.0.Final"/> <dependency org="org.hibernate" name="hibernate-c3p0" rev="3.6.0.Final"/> <dependency org="org.hibernate" name="hibernate-entitymanager" rev="3.6.0.Final"/> <dependency org="org.hibernate" name="hibernate-search" rev="3.3.0.Final"/> <dependency org="mysql" name="mysql-connector-java" rev="5.1.13"/> <!-- PrettyFaces --> <dependency org="com.ocpsoft" name="prettyfaces-jsf2" rev="3.0.1"/> <!-- SLF4J --> <dependency org="org.slf4j" name="slf4j-api" rev="1.6.1"/> <dependency org="org.slf4j" name="slf4j-log4j12" rev="1.6.1"/> <!-- XOM --> <dependency org="xom" name="xom" rev="1.2.5"/> <!-- JSF Unit --> <dependency org="org.jboss.jsfunit" name="jboss-jsfunit-core" rev="1.3.0.Final" conf="development"/> </dependencies>我正在部署到tomcat 6.0I am deploying to tomcat 6.0 更新在下面的答案之后,我通过将以下依赖项添加到我的ivy.xml来解决这个问题:After the answer below, I solved this by adding the following dependency to my ivy.xml:<dependency org="org.hibernate.javax.persistence" name="hibernate-jpa-2.0-api" rev="1.0.0.Final"/>然后将这个jar放在Eclipse的构建顺序选项卡下的其他所有内容中。then putting this jar above everything else under Eclipse's build order tab.我使用的是JRE / JDK 6.I was using JRE/JDK 6.推荐答案您的Java Persistence API版本错误:You have a wrong version of the Java Persistence API:参见 OneToMany.orphanRemoval()文档 从那以后:Java Persinstence 2.0它不包含在JEE5中。It is not included with JEE5. 编辑: http://wiki.eclipse.org/EclipseLink/Examples/JPA/Tomcat_Web_Tutorial JPA的限制 Limitations to JPA As Tomcat不是JEE5兼容服务器,对JPA有一些限制。 As Tomcat is not a JEE5 compatible server, there are some limitiations to JPA. 没有动态编织(instr umentation) - 实体的静态编织仍可通过EclipseLink获取 没有@EJB注入会话bean(包含EntityManager)可用 - 直接使用持久性工厂和管理器 没有@PersistenceContext注入容器管理的持久性单元 - 使用Persistence.createEntityManagerFactory(JTA_PU_NAME)如果Tomcat不符合JEE5,我相信它不会符合JEE6标准。If the Tomcat is not JEE5 compliant, I am sure it will not be JEE6 compliant. 这篇关于java.lang.NoSuchMethodError:javax.persistence.OneToMany.orphanRemoval()Z的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-28 06:02