2014-03-27 154 views
0

我試圖在Tomcat 8.0.3上部署我的Spring應用程序。 servlet容器使用jdk 1.0.7_51。我能夠通過部署在Tomcat 8.0.3上

做部署MVN tomcat7:插件

但是當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依賴性:樹| FINDSTR蝕

,我得到這樣的結果

[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

投訴給誰就給誰給你org.eclipse.persistence.sessions。 coordination.CommandProcessor,該jar文件格式不正確。或者關閉安全管理器。 – bmargulies

+1

你不是還混合了Eclipselink的2個版本嗎? 2.3.2和2.5.1? –

+0

@bmargulies在未啓用安全管理器的情況下,您會看到該錯誤 –

回答

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,則可能會破壞某些內容。

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版本