我有一个maven项目,使用spring,hibernate(3.6.4),GWT(2.3),drools,.... 在我开始使用hibernate OneToMany,ManyToMany关系之前,一切都工作得很好......
当我从“mvn jetty:run”运行应用程序时,它可以运行,但是当我从gwt嵌入式jetty运行应用程序时,以及我在应用程序中嵌入的jetty版本时,我得到:
[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
这些是罐子:
[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
我发现有人建议这意味着有一个jpa 1.0 jar的引用,但我似乎无法找到...我使用maven树,maven类路径搜索,查找整个目录的jar ...除了hibernate jpa 2.0 v.1.0 final之外,我找不到任何与jpa或persistence相关的东西。我的类路径上没有ejb3-persistance.jar ...
我想做什么?
非常感谢。
答案 0 :(得分:14)
答案 1 :(得分:7)
我们遇到了完全相同的问题并输出了OneToMany.class.getProtectionDomain()。getCodeSource()。getLocation()向我们展示了问题。由于我们的pom中存在过时的依赖性,我们正在接收ejb3 JAR。非常感谢您发布此解决方案!
顺便说一下,如果你正在使用Eclipse,请记得运行mvn eclipse:eclipse,否则.classpath仍将引用不需要的JAR。
答案 2 :(得分:1)
谢谢....这对我有同样的问题。当作为Web应用程序运行时,我得到了“坏”路径但是当作为应用程序运行时,我得到了“好”路径。
坏 / C:/ Program Files(x86)/IBM/SDP/runtimes/base_v7/plugins/javax.j2ee.persistence.jar
好 /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
答案 3 :(得分:0)
它导致在实体类中使用persistence-api注释来解决这个问题,让你的类路径包含
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.4.0.GA</version>
<scope>provided</scope>
</dependency>
这种依赖使用ejb3-persistence.jar