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

23,290

Solution 1

i had the same problem, i soved it by removing the persistence-api-1.0.2.jar from the classpath

Solution 2

We had the exact same problem and outputting OneToMany.class.getProtectionDomain().getCodeSource().getLocation() showed us the problem. We were picking up ejb3 JAR due to a stale dependency in our pom. Thank you very much for posting this solution!

By the way, remember to run mvn eclipse:eclipse if you're using Eclipse, else the .classpath will still refer to the unwanted JAR.

Solution 3

Thanks....This helped me with the same problem. When running as a web app I got the "Bad" path but when running as an application I got the "Good" path.

Bad /C:/Program Files (x86)/IBM/SDP/runtimes/base_v7/plugins/javax.j2ee.persistence.jar

Good /C:/hibernate-release-4.1.7.Final%20(1)/hibernate-release-4.1.7.Final/lib/required/hibernate-jpa-2.0-api-1.0.1.Final.jar

Share:
23,290
AhHatem
Author by

AhHatem

Updated on April 12, 2020

Comments

  • AhHatem
    AhHatem about 4 years

    I have a maven project that uses spring, hibernate (3.6.4), GWT(2.3), drools,.... Everything used to work fine till I began using hibernate OneToMany, ManyToMany relations...

    When I run the app from "mvn jetty:run", it works, but When I run the app from gwt embedded jetty and from a jetty version that I have embedded in my app, I get:

    [INFO] Caused by: java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()Z
    [INFO]  at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1912)
    [INFO]  at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:796)
    [INFO]  at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:707)
    [INFO]  at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:4035)
    [INFO]  at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3989)
    [INFO]  at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1398)
    [INFO]  at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1375)
    [INFO]  at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:717)
    [INFO]  at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
    [INFO]  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
    [INFO]  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
    [INFO]  ... 95 more
    

    These are the jars:

       [INFO] +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.0.Final:compile
      [INFO] +- junit:junit:jar:4.8.2:test
      [INFO] +- log4j:log4j:jar:1.2.16:compile
      [INFO] +- org.slf4j:slf4j-api:jar:1.6.1:compile
      [INFO] +- org.slf4j:jcl-over-slf4j:jar:1.6.1:compile
      [INFO] +- org.slf4j:slf4j-log4j12:jar:1.6.1:compile
      [INFO] +- org.aspectj:aspectjrt:jar:1.6.11:compile
      [INFO] +- org.aspectj:aspectjweaver:jar:1.6.11:compile
      [INFO] +- javax.servlet:servlet-api:jar:2.5:compile
      [INFO] +- net.sf.flexjson:flexjson:jar:2.1:compile
      [INFO] +- org.apache.commons:commons-io:jar:1.3.2:compile
      [INFO] +- org.springframework.roo:org.springframework.roo.annotations:jar:1.1.5.RELEASE:provided
      [INFO] +- org.springframework:spring-core:jar:3.0.5.RELEASE:compile
      [INFO] |  \- org.springframework:spring-asm:jar:3.0.5.RELEASE:compile
      [INFO] +- org.springframework:spring-test:jar:3.0.5.RELEASE:test (scope not updated to compile)
      [INFO] +- org.springframework:spring-context:jar:3.0.5.RELEASE:compile
      [INFO] |  +- org.springframework:spring-beans:jar:3.0.5.RELEASE:compile
      [INFO] |  \- org.springframework:spring-expression:jar:3.0.5.RELEASE:compile
      [INFO] +- org.springframework:spring-aop:jar:3.0.5.RELEASE:compile
      [INFO] |  \- aopalliance:aopalliance:jar:1.0:compile
      [INFO] +- org.springframework:spring-aspects:jar:3.0.5.RELEASE:compile
      [INFO] |  \- org.springframework:spring-context-support:jar:3.0.5.RELEASE:compile
      [INFO] +- org.springframework:spring-tx:jar:3.0.5.RELEASE:compile
      [INFO] +- org.hsqldb:hsqldb:jar:1.8.0.10:compile
      [INFO] +- org.hibernate:hibernate-core:jar:3.6.4.Final:compile
      [INFO] |  +- antlr:antlr:jar:2.7.6:compile
      [INFO] |  +- commons-collections:commons-collections:jar:3.1:compile
      [INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
      [INFO] |  \- org.hibernate:hibernate-commons-annotations:jar:3.2.0.Final:compile
      [INFO] +- org.hibernate:hibernate-entitymanager:jar:3.6.4.Final:compile
      [INFO] |  \- javassist:javassist:jar:3.12.0.GA:compile
      [INFO] +- org.hibernate:hibernate-validator:jar:4.1.0.Final:compile
      [INFO] +- javax.validation:validation-api:jar:1.0.0.GA:compile
      [INFO] +- cglib:cglib-nodep:jar:2.2:compile
      [INFO] +- javax.transaction:jta:jar:1.1:compile
      [INFO] +- org.springframework:spring-jdbc:jar:3.0.5.RELEASE:compile
      [INFO] +- org.springframework:spring-orm:jar:3.0.5.RELEASE:compile
      [INFO] +- commons-pool:commons-pool:jar:1.5.4:compile
      [INFO] +- commons-dbcp:commons-dbcp:jar:1.3:compile
      [INFO] +- org.springframework:spring-web:jar:3.0.5.RELEASE:compile
      [INFO] +- org.springframework:spring-webmvc:jar:3.0.5.RELEASE:compile
      [INFO] +- org.springframework.webflow:spring-js-resources:jar:2.2.1.RELEASE:compile
      [INFO] +- commons-digester:commons-digester:jar:2.0:compile
      [INFO] |  \- commons-beanutils:commons-beanutils:jar:1.8.0:compile
      [INFO] +- commons-fileupload:commons-fileupload:jar:1.2.1:compile
      [INFO] +- javax.servlet:jstl:jar:1.2:compile
      [INFO] +- javax.servlet.jsp.jstl:jstl-api:jar:1.2:compile
      [INFO] +- org.glassfish.web:jstl-impl:jar:1.2:compile
      [INFO] +- javax.el:el-api:jar:1.0:provided
      [INFO] +- joda-time:joda-time:jar:1.6:compile
      [INFO] +- javax.servlet.jsp:jsp-api:jar:2.1:compile
      [INFO] +- commons-codec:commons-codec:jar:1.4:compile
      [INFO] +- com.google.gwt:gwt-servlet:jar:2.3.0:compile
      [INFO] +- com.google.gwt:gwt-user:jar:2.3.0:provided
      [INFO] +- org.json:json:jar:20090211:compile
      [INFO] +- com.google.gwt.inject:gin:jar:1.5.0:compile
      [INFO] |  +- com.google.inject:guice:jar:3.0-rc2:compile
      [INFO] |  |  \- javax.inject:javax.inject:jar:1:compile
      [INFO] |  \- com.google.inject.extensions:guice-assistedinject:jar:3.0-rc2:compile
      [INFO] +- javax.validation:validation-api:jar:sources:1.0.0.GA:compile
      [INFO] +- xalan:xalan:jar:2.7.1:compile
      [INFO] |  \- xalan:serializer:jar:2.7.1:compile
      [INFO] |     \- xml-apis:xml-apis:jar:1.3.04:compile
      [INFO] +- mysql:mysql-connector-java:jar:5.1.17:compile
      [INFO] +- proj.Dependencies:advancedComponents:jar:2.0.6:compile
      [INFO] +- proj.Dependencies:gwtent:jar:2.0RC1:compile
      [INFO] +- proj.Dependencies:gwtent-orm:jar:2.0RC1:compile
      [INFO] +- proj.Dependencies:gwt-crypto:jar:3.0.0:compile
      [INFO] +- javax.mail:mail:jar:1.4.4:compile
      [INFO] |  \- javax.activation:activation:jar:1.1:compile
      [INFO] +- com.thoughtworks.paranamer:paranamer-generator:jar:2.3:compile
      [INFO] |  +- com.thoughtworks.qdox:qdox:jar:1.12:compile
      [INFO] |  \- asm:asm:jar:3.3:compile
      [INFO] +- com.thoughtworks.paranamer:paranamer:jar:2.3:compile
      [INFO] +- com.lowagie:itext:jar:2.0.8:compile
      [INFO] |  +- bouncycastle:bcmail-jdk14:jar:138:compile
      [INFO] |  \- bouncycastle:bcprov-jdk14:jar:138:compile
      [INFO] +- proj.Dependencies:core-renderer:jar:8:compile
      [INFO] +- proj.Dependencies:core-renderer-minimal:jar:8:compile
      [INFO] +- proj.Dependencies:xml-apis-xerces:jar:2.9.1:compile
      [INFO] +- org.apache.poi:poi:jar:3.8-beta4:compile
      [INFO] +- org.apache.poi:poi-ooxml:jar:3.8-beta4:compile
      [INFO] +- org.apache.poi:poi-ooxml-schemas:jar:3.8-beta4:compile
      [INFO] |  \- org.apache.xmlbeans:xmlbeans:jar:2.3.0:compile
      [INFO] |     \- stax:stax-api:jar:1.0.1:compile
      [INFO] +- proj.Dependencies:gwt_i18n_server:jar:1.0:compile
      [INFO] +- org.mortbay.jetty:jsp-api-2.1-glassfish:jar:2.1.v20100127:compile
      [INFO] +- org.mortbay.jetty:jsp-2.1-glassfish:jar:2.1.v20100127:compile
      [INFO] |  +- org.eclipse.jdt.core.compiler:ecj:jar:3.5.1:compile
      [INFO] |  \- ant:ant:jar:1.6.5:compile
      [INFO] +- org.eclipse.jetty:jetty-server:jar:7.2.2.v20101205:compile
      [INFO] |  +- org.eclipse.jetty:jetty-continuation:jar:7.2.2.v20101205:compile
      [INFO] |  \- org.eclipse.jetty:jetty-http:jar:7.2.2.v20101205:compile
      [INFO] |     \- org.eclipse.jetty:jetty-io:jar:7.2.2.v20101205:compile
      [INFO] +- org.eclipse.jetty:jetty-webapp:jar:7.2.2.v20101205:compile
      [INFO] |  \- org.eclipse.jetty:jetty-xml:jar:7.2.2.v20101205:compile
      [INFO] |     \- org.eclipse.jetty:jetty-util:jar:7.2.2.v20101205:compile
      [INFO] +- org.eclipse.jetty:jetty-servlet:jar:7.2.2.v20101205:compile
      [INFO] |  \- org.eclipse.jetty:jetty-security:jar:7.2.2.v20101205:compile
      [INFO] +- org.drools:drools-core:jar:5.3.1.Final:compile
      [INFO] |  \- org.mvel:mvel2:jar:2.1.0.drools4:compile
      [INFO] +- org.drools:droolsjbpm-knowledge:pom:5.3.1.Final:compile
      [INFO] +- org.drools:droolsjbpm-integration:pom:5.3.1.Final:compile
      [INFO] +- org.drools:droolsjbpm-tools:pom:5.3.1.Final:compile
      [INFO] +- org.drools:droolsjbpm-parent:pom:5.3.1.Final:compile
      [INFO] +- org.drools.planner:drools-planner:pom:5.3.1.Final:compile
      [INFO] +- org.drools:drools-multiproject:pom:5.3.1.Final:compile
      [INFO] +- org.drools:knowledge-api:jar:5.3.1.Final:compile
      [INFO] +- org.jbpm:jbpm-flow-builder:jar:5.2.0-SNAPSHOT:compile
      [INFO] |  \- org.jbpm:jbpm-flow:jar:5.2.0-SNAPSHOT:compile
      [INFO] \- org.drools:drools-compiler:jar:5.3.1.Final:compile
      [INFO]    +- org.antlr:antlr-runtime:jar:3.3:compile
      [INFO]    +- org.antlr:antlr:jar:3.3:compile
      [INFO]    \- org.antlr:stringtemplate:jar:3.2.1:compile
    

    I have found people suggesting that it means there is a reference to a jpa 1.0 jar, but I can't seem to find that... I searched using maven tree, maven classpath, looking the entire directory for jars.. I can't find anything related to jpa or persistence except the hibernate jpa 2.0 v. 1.0 final. I don't have ejb3-persistance.jar on my classpath...

    What am I suppose to do?

    Thanks a lot.