我试图在Tomcat 8.0.3上部署我的spring应用程序。 servlet容器使用jdk 1.0.7_51。我能够通过
进行部署mvn tomcat7:plugin
但是当Tomcat尝试运行应用程序时。在日志文件中,我得到了这个例外:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in URL [file:/home/myApp/apache-tomcat-8.0.3/webapps/myApp/WEB-INF/classes/database.xml]: Invocation of init method failed; nested exception is java.lang.SecurityException: class "org.eclipse.persistence.sessions.coordination.CommandProcessor"'s signer information does not match signer information of other classes in the same package
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:420)
at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:277)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:139)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.<init>(PersistenceExceptionTranslationInterceptor.java:79)
at org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.<init>(PersistenceExceptionTranslationAdvisor.java:70)
at org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:103)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1475)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1443)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
... 55 more
我也跑
mvn依赖:tree | findstr eclipse
我得到了这个结果
[INFO] | | +- org.eclipse.persistence:org.eclipse.persistence.jpa:jar:2.5.1:compile
[INFO] | | | +- org.eclipse.persistence:javax.persistence:jar:2.1.0:compile
[INFO] | | | +- org.eclipse.persistence:org.eclipse.persistence.asm:jar:2.5.1:compile
[INFO] | | | +- org.eclipse.persistence:org.eclipse.persistence.antlr:jar:2.5.1:compile
[INFO] | | | +- org.eclipse.persistence:org.eclipse.persistence.jpa.jpql:jar:2.5.1:compile
[INFO] | | | \- org.eclipse.persistence:org.eclipse.persistence.core:jar:2.5.1:compile
[INFO] | | \- org.eclipse.persistence:eclipselink:jar:2.3.2:compile
[INFO] | | +- eclipse:jdtcore:jar:3.1.0:compile
我该如何解决?
答案 0 :(得分:1)
您有多个JAR提供包org.eclipse.persistence.sessions.coordination
中的类,但其中一些JAR是签名的,一些是未签名的。 Java类加载器不允许这样做。
修复的难易程度取决于具体情况。
如果签名JAR提供的类也由未签名的JAR提供,并且应用程序CAN在没有签名的JAR的情况下运行,则只需删除已签名的JAR。
如果未签名的JAR提供的类也由签名的JAR提供,并且应用程序CAN在没有未签名的JAR的情况下运行,则只需删除未签名的JAR。
如果签名JAR提供的类也由未签名的JAR提供,但是应用程序无法在没有签名的JAR的情况下运行,那么您将需要强制Tomcat加载未签名的JAR (s)首先。以下是ASF如何通过Jira在Tomcat 8上运行Jira 6.2解决此问题。这需要添加到Web应用程序的context.xml中。
<Resources>
<!-- Trick to force this JAR to be searched for classes before all others
to work around a Jira bug -->
<PreResources className="org.apache.catalina.webresources.FileResourceSet"
base="${catalina.base}/webapps/jira/WEB-INF/lib/jira-api-6.2.jar"
webAppMount="/WEB-INF/lib/jira-api-6.2.jar" />
</Resources>
与删除一样,您可以将其翻转以使签名的JAR首先加载。
如果上述方法都不起作用,您可以解包已签名的JAR并在没有签名的情况下重新打包它们,但如果在任何地方都需要签名的JAR,则可能会破坏某些内容。
答案 1 :(得分:0)
我解决了改变我的pom:
<dependencies>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.3.2</version>
</dependency>
</dependencies>
为:
<dependencies>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.5.1</version>
</dependency>
</dependencies>
我只修改了eclipseLink的版本