javax.persistence.JoinColumn.foreignKey()Ljavax /持久/ ForeignKey的; Weblogic JPA 2.0

时间:2016-06-07 14:56:22

标签: hibernate jpa

目前升级到JPA 2.1对我来说不是一个好主意。但是我遇到了很多问题。我正在使用WebLogic 10.3.6.0,我正在尝试清除旧的Hibernate使用HibernateTemplate,但是一旦我配置了所有内容,我就会收到以下错误:

java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;

POM.file

 <!-- =======JPA/Hibernate======== -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.2.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-jpa</artifactId>
            <version>1.9.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.0-api</artifactId>
            <version>1.0.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>5.2.4.Final</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>5.1.0.Final</version>
        </dependency>

        <dependency>
            <groupId>org.apache.openjpa</groupId>
            <artifactId>openjpa-persistence</artifactId>
            <version>2.4.0</version>
        </dependency>

我已根据Oracle Applying the Patch Using OPatch

中的说明更改了PRE_CLASSPATH(示例:PRE_CLASSPATH=%MW_HOME%\oracle_common\modules\javax.persistence_2.1.jar;%MW_HOME%\wlserver\modules\com.oracle.weblogic.jpa21support_1.0.0.0_2-1.jar

依赖树:

 --- maven-dependency-plugin:2.1:tree (default-cli) @ request ---
[INFO] mil.army.keystone:request:war:2.07
[INFO] +- struts:struts:jar:1.2.9:compile
[INFO] |  +- commons-beanutils:commons-beanutils:jar:1.7.0:compile
[INFO] |  +- commons-digester:commons-digester:jar:1.6:compile
[INFO] |  +- commons-fileupload:commons-fileupload:jar:1.0:compile
[INFO] |  +- commons-validator:commons-validator:jar:1.1.4:compile
[INFO] |  +- oro:oro:jar:2.0.7:compile
[INFO] |  \- xalan:xalan:jar:2.5.1:compile
[INFO] +- javax.servlet:servlet-api:jar:2.5:provided
[INFO] +- javax.servlet:jsp-api:jar:2.0:provided
[INFO] +- javax.servlet:jstl:jar:1.2:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.13:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.7.13:compile
[INFO] +- org.slf4j:log4j-over-slf4j:jar:1.7.13:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.1.3:compile
[INFO] |  \- ch.qos.logback:logback-core:jar:1.1.3:compile
[INFO] +- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] +- commons-betwixt:commons-betwixt:jar:0.8:compile
[INFO] |  \- commons-beanutils:commons-beanutils-core:jar:1.7.0:compile
[INFO] +- commons-chain:commons-chain:jar:1.0:compile
[INFO] +- commons-codec:commons-codec:jar:1.2:compile
[INFO] +- org.apache.axis:axis:jar:1.4:compile
[INFO] +- javax.xml:jaxrpc-api:jar:1.1:compile
[INFO] +- regexp:regexp:jar:1.3:compile
[INFO] +- org.apache.xmlgraphics:fop:jar:1.0:compile
[INFO] |  +- org.apache.xmlgraphics:xmlgraphics-commons:jar:1.4:compile
[INFO] |  +- org.apache.xmlgraphics:batik-svg-dom:jar:1.7:compile
[INFO] |  |  +- org.apache.xmlgraphics:batik-anim:jar:1.7:compile
[INFO] |  |  +- org.apache.xmlgraphics:batik-css:jar:1.7:compile
[INFO] |  |  +- org.apache.xmlgraphics:batik-dom:jar:1.7:compile
[INFO] |  |  +- org.apache.xmlgraphics:batik-parser:jar:1.7:compile
[INFO] |  |  \- org.apache.xmlgraphics:batik-util:jar:1.7:compile
[INFO] |  +- org.apache.xmlgraphics:batik-bridge:jar:1.7:compile
[INFO] |  |  +- org.apache.xmlgraphics:batik-script:jar:1.7:compile
[INFO] |  |  \- org.apache.xmlgraphics:batik-xml:jar:1.7:compile
[INFO] |  +- org.apache.xmlgraphics:batik-awt-util:jar:1.7:compile
[INFO] |  +- org.apache.xmlgraphics:batik-gvt:jar:1.7:compile
[INFO] |  +- org.apache.xmlgraphics:batik-transcoder:jar:1.7:compile
[INFO] |  |  \- org.apache.xmlgraphics:batik-svggen:jar:1.7:compile
[INFO] |  +- org.apache.xmlgraphics:batik-extension:jar:1.7:compile
[INFO] |  +- org.apache.xmlgraphics:batik-ext:jar:1.7:compile
[INFO] |  +- commons-io:commons-io:jar:1.3.1:compile
[INFO] |  +- org.apache.avalon.framework:avalon-framework-api:jar:4.3.1:compile
[INFO] |  \- org.apache.avalon.framework:avalon-framework-impl:jar:4.3.1:compile
[INFO] +- oracle:ojdbc6:jar:11.2.0.4.0:provided
[INFO] +- org.springframework:spring-webmvc:jar:4.2.4.RELEASE:compile
[INFO] |  +- org.springframework:spring-beans:jar:4.2.4.RELEASE:compile
[INFO] |  +- org.springframework:spring-core:jar:4.2.4.RELEASE:compile
[INFO] |  +- org.springframework:spring-expression:jar:4.2.4.RELEASE:compile
[INFO] |  \- org.springframework:spring-web:jar:4.2.4.RELEASE:compile
[INFO] +- org.springframework:spring-orm:jar:4.2.4.RELEASE:compile
[INFO] |  +- org.springframework:spring-jdbc:jar:4.2.4.RELEASE:compile
[INFO] |  \- org.springframework:spring-tx:jar:4.2.4.RELEASE:compile
[INFO] +- org.springframework:spring-aspects:jar:4.2.4.RELEASE:compile
[INFO] |  \- org.aspectj:aspectjweaver:jar:1.8.7:compile
[INFO] +- org.apache.ws.security:wss4j:jar:1.5.12:compile
[INFO] +- org.apache.santuario:xmlsec:jar:1.4.4:compile
[INFO] +- org.eclipse.birt.runtime.3_7_1:Tidy:jar:1:compile
[INFO] +- cglib:cglib:jar:2.1:compile
[INFO] |  +- asm:asm:jar:1.5.3:compile
[INFO] |  +- asm:asm-util:jar:1.3.4:compile
[INFO] |  \- aspectwerkz:aspectwerkz-core:jar:0.8.1:compile
[INFO] +- commons-discovery:commons-discovery:jar:0.2:compile
[INFO] +- jaxen:jaxen:jar:1.1.1:compile
[INFO] |  +- jdom:jdom:jar:1.0:compile
[INFO] |  +- xerces:xercesImpl:jar:2.6.2:compile
[INFO] |  \- xom:xom:jar:1.0:compile
[INFO] |     \- com.ibm.icu:icu4j:jar:2.6.1:compile
[INFO] +- antlr:antlr:jar:2.7.6:compile
[INFO] +- dom4j:dom4j:jar:1.6.1:compile
[INFO] +- org.jdom:jdom:jar:1.1:compile
[INFO] +- wsdl4j:wsdl4j:jar:1.6.1:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.4:compile
[INFO] +- org.bouncycastle:bcprov-jdk15on:jar:1.54:compile
[INFO] +- org.aspectj:aspectjrt:jar:1.8.8:compile
[INFO] +- org.webjars:jquery:jar:1.12.4:provided
[INFO] +- org.webjars:jquery-ui-themes:jar:1.11.0:provided
[INFO] +- org.webjars:jquery-ui:jar:1.11.1:provided
[INFO] +- org.springframework:spring-context:jar:4.2.6.RELEASE:compile
[INFO] |  \- org.springframework:spring-aop:jar:4.2.6.RELEASE:compile
[INFO] |     \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework.data:spring-data-jpa:jar:1.9.0.RELEASE:compile
[INFO] |  \- org.springframework.data:spring-data-commons:jar:1.11.0.RELEASE:compile
[INFO] +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.0.Final:compile
[INFO] +- org.hibernate:hibernate-validator:jar:5.2.4.Final:compile
[INFO] |  +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] |  +- org.jboss.logging:jboss-logging:jar:3.2.1.Final:compile
[INFO] |  \- com.fasterxml:classmate:jar:1.1.0:compile
[INFO] +- org.hibernate:hibernate-entitymanager:jar:5.1.0.Final:compile
[INFO] |  +- org.hibernate:hibernate-core:jar:5.1.0.Final:compile
[INFO] |  |  \- org.jboss:jandex:jar:2.0.0.Final:compile
[INFO] |  +- org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile
[INFO] |  +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] |  +- org.javassist:javassist:jar:3.20.0-GA:compile
[INFO] |  \- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1.1:compile
[INFO] +- org.apache.openjpa:openjpa-persistence:jar:2.4.0:compile
[INFO] |  +- org.apache.openjpa:openjpa-kernel:jar:2.4.0:compile
[INFO] |  |  +- org.apache.openjpa:openjpa-lib:jar:2.4.0:compile
[INFO] |  |  |  +- commons-lang:commons-lang:jar:2.4:compile
[INFO] |  |  |  \- net.sourceforge.serp:serp:jar:1.15.1:compile
[INFO] |  |  +- org.apache.geronimo.specs:geronimo-jms_1.1_spec:jar:1.1.1:compile
[INFO] |  |  +- commons-pool:commons-pool:jar:1.5.4:compile
[INFO] |  |  \- org.apache.xbean:xbean-asm5-shaded:jar:3.17:compile
[INFO] |  \- org.apache.geronimo.specs:geronimo-jpa_2.0_spec:jar:1.1:compile
[INFO] +- org.springframework:spring-test:jar:4.2.6.RELEASE:test
[INFO] \- junit:junit:jar:4.8.1:test (scope not updated to compile)

2 个答案:

答案 0 :(得分:0)

也许你应该升级这个库

    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.0-api</artifactId>
        <version>1.0.0.Final</version>
    </dependency>

到版本2.1?

此方法“javax.persistence.JoinColumn.foreignKey()”在jpa 2.1中引入

答案 1 :(得分:0)

升级到 hibernate-core-4.3.5.Final 时,我也遇到了问题 在使用Tomcat的localhost中,我可以很好地启动,但是当我在WL中部署时,我遇到了相同的错误。

将其添加到文件 weblogic-application.xml 是我的解决方案:

<prefer-application-packages>

        <!-- jpa -->
        <package-name>javax.persistence.*</package-name>
        <package-name>javax.persistence.criteria.*</package-name>
        <package-name>javax.persistence.metamodel.*</package-name>
        <package-name>javax.persistence.spi.*</package-name>

</prefer-application-packages>