当我尝试在tomcat8(java 1.8_65)上使用已部署的war文件启动Spring MVC应用程序时,我收到异常:
上下文初始化失败错误创建名称为' entityManagerFactory'的bean在biz.aspsol.solarix.init.configuration.WebAppConfig中定义:调用init方法失败;嵌套异常是java.lang.NoSuchMethodError:javax.persistence.JoinTable.indexes()[Ljavax / persistence / Index;
奇怪的是,我可以在没有问题的情况下运行应用程序,但是使用war文件的部署不起作用。
这是我的maven依赖树:
[INFO] +- org.springframework:spring-context:jar:4.2.2.RELEASE:compile
[INFO] | \- org.springframework:spring-aop:jar:4.2.2.RELEASE:compile
[INFO] +- org.springframework:spring-core:jar:4.2.2.RELEASE:compile
[INFO] | \- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- org.springframework:spring-expression:jar:4.2.2.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:4.2.2.RELEASE:compile
[INFO] +- org.springframework:spring-web:jar:4.2.2.RELEASE:compile
[INFO] +- org.springframework:spring-context-support:jar:4.2.2.RELEASE:compile
[INFO] +- org.springframework:spring-beans:jar:4.2.2.RELEASE:compile
[INFO] +- org.springframework.data:spring-data-jpa:jar:1.8.2.RELEASE:compile
[INFO] | +- org.springframework.data:spring-data-commons:jar:1.10.2.RELEASE:compile
[INFO] | +- org.springframework:spring-orm:jar:4.0.9.RELEASE:compile
[INFO] | | \- org.springframework:spring-jdbc:jar:4.0.9.RELEASE:compile
[INFO] | +- org.springframework:spring-tx:jar:4.0.9.RELEASE:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.12:compile
[INFO] | \- org.slf4j:jcl-over-slf4j:jar:1.7.12:runtime
[INFO] +- org.springframework.security:spring-security-web:jar:4.0.2.RELEASE:compile
[INFO] | +- aopalliance:aopalliance:jar:1.0:compile
[INFO] | \- org.springframework.security:spring-security-core:jar:4.0.2.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-config:jar:4.0.2.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-taglibs:jar:4.0.2.RELEASE:compile
[INFO] | \- org.springframework.security:spring-security-acl:jar:4.0.2.RELEASE:compile
[INFO] +- org.thymeleaf:thymeleaf-spring4:jar:2.1.4.RELEASE:compile
[INFO] +- org.thymeleaf:thymeleaf:jar:2.1.4.RELEASE:compile
[INFO] | +- ognl:ognl:jar:3.0.8:compile
[INFO] | \- org.unbescape:unbescape:jar:1.1.0.RELEASE:compile
[INFO] +- org.thymeleaf.extras:thymeleaf-extras-springsecurity4:jar:2.1.2.RELEASE:compile
[INFO] +- nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:jar:1.3.0:compile
[INFO] | \- org.codehaus.groovy:groovy:jar:2.4.3:compile
[INFO] +- org.hibernate:hibernate-core:jar:4.3.6.Final:compile
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.1.3.GA:compile
[INFO] | +- org.jboss.logging:jboss-logging-annotations:jar:1.2.0.Beta1:compile
[INFO] | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.0.0.Final:compile
[INFO] | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | | \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] | +- org.hibernate.common:hibernate-commons-annotations:jar:4.0.5.Final:compile
[INFO] | +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] | +- antlr:antlr:jar:2.7.7:compile
[INFO] | \- org.jboss:jandex:jar:1.1.0.Final:compile
[INFO] +- org.hibernate:hibernate-validator:jar:5.2.1.Final:compile
[INFO] | \- com.fasterxml:classmate:jar:1.1.0:compile
[INFO] +- org.hibernate:hibernate-entitymanager:jar:5.0.3.Final:compile
[INFO] | \- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1.1:compile
[INFO] +- org.aspectj:aspectjrt:jar:1.8.6:runtime (scope not updated to compile)
[INFO] +- org.aspectj:aspectjtools:jar:1.8.6:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.6.1:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.6.1:compile
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.6.1:compile
[INFO] +- org.apache.velocity:velocity:jar:1.7:compile
[INFO] | +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] | \- commons-lang:commons-lang:jar:2.4:compile
[INFO] +- org.apache.velocity:velocity-tools:jar:2.0:compile
[INFO] | +- commons-beanutils:commons-beanutils:jar:1.7.0:compile
[INFO] | +- commons-digester:commons-digester:jar:1.8:compile
[INFO] | +- commons-chain:commons-chain:jar:1.1:compile
[INFO] | +- commons-validator:commons-validator:jar:1.3.1:compile
[INFO] | +- oro:oro:jar:2.0.8:compile
[INFO] | +- sslext:sslext:jar:1.2-0:compile
[INFO] | +- org.apache.struts:struts-core:jar:1.3.8:compile
[INFO] | +- org.apache.struts:struts-taglib:jar:1.3.8:compile
[INFO] | \- org.apache.struts:struts-tiles:jar:1.3.8:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.12:compile
[INFO] | \- log4j:log4j:jar:1.2.17:compile
[INFO] +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:provided
[INFO] +- javax.mail:mail:jar:1.4.7:compile
[INFO] | \- javax.activation:activation:jar:1.1:compile
[INFO] +- org.postgresql:postgresql:jar:9.4-1202-jdbc42:compile
[INFO] +- org.apache.commons:commons-dbcp2:jar:2.1.1:compile
[INFO] | \- org.apache.commons:commons-pool2:jar:2.4.2:compile
[INFO] +- commons-io:commons-io:jar:2.4:compile
[INFO] +- net.sf.ehcache:ehcache:jar:2.10.0:compile
[INFO] +- org.javassist:javassist:jar:3.20.0-GA:compile
[INFO] +- com.braintreepayments.gateway:braintree-java:jar:2.49.0:compile
[INFO] +- org.xhtmlrenderer:flying-saucer-pdf-itext5:jar:9.0.8:compile
[INFO] | \- org.xhtmlrenderer:flying-saucer-core:jar:9.0.8:compile
[INFO] +- org.apache.pdfbox:pdfbox:jar:1.8.10:compile
[INFO] | +- org.apache.pdfbox:fontbox:jar:1.8.10:compile
[INFO] | \- org.apache.pdfbox:jempbox:jar:1.8.10:compile
[INFO] +- org.bouncycastle:bcprov-jdk15on:jar:1.52:compile
[INFO] +- org.bouncycastle:bcmail-jdk15on:jar:1.52:compile
[INFO] | \- org.bouncycastle:bcpkix-jdk15on:jar:1.52:compile
[INFO] +- org.json:json:jar:20150729:compile
[INFO] +- com.google.maps:google-maps-services:jar:0.1.8:compile
[INFO] | +- com.squareup.okhttp:okhttp:jar:2.0.0:compile
[INFO] | | \- com.squareup.okio:okio:jar:1.0.0:compile
[INFO] | +- com.google.code.gson:gson:jar:2.3.1:compile
[INFO] | \- joda-time:joda-time:jar:2.4:compile
[INFO] +- org.apache.poi:poi:jar:3.13:compile
[INFO] | \- commons-codec:commons-codec:jar:1.9:compile
[INFO] \- com.itextpdf:itextpdf:jar:5.5.7:compile
答案 0 :(得分:0)
您很可能在tomcat中部署了旧版本的JPA api。 这就是为什么在从IntelliJ部署时没有看到异常的原因。
indexes
属性已在JPA 2.1中引入@JoinTable
。如果您使用旧版本的JPA,那么您将在运行时获得完全相同的异常。
检查$CATALINA_BASE/lib
文件夹
答案 1 :(得分:0)
我找到了问题的解决方案。我已将hibernate-jpa-2.1-api依赖项包含到我的pom.xml文件中。
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>