2012-02-19 61 views
1

我最近開始嘗試升級Struts2的/春/ Hibernate應用程序的一些依賴關係是幾年過時的 - 主要是爲了儘量挑選注入@Enumerated註釋。聚甲醛是一路走來,這是一個很好的副作用調試java.lang.IncompatibleClassChangeError:實現類錯誤(春/休眠/ Struts的)

所有的代碼編譯和單元測試通過越來越乾淨,但服務器不會與

"Caused by: java.lang.IncompatibleClassChangeError: Implementing class"

錯誤信息啓動。

我跟着幾個線程談論的依賴追蹤版本不匹配 - 人們似乎常常得到兩個版本的Hibernate。我不認爲我有一個問題:

[INFO] [snip MyProjectName] 
[INFO] \- org.hibernate:hibernate-entitymanager:jar:3.5.6-Final:compile 
[INFO] +- org.hibernate:hibernate-core:jar:3.5.6-Final:compile 
[INFO] \- org.hibernate:hibernate-annotations:jar:3.5.6-Final:compile 
[INFO]  \- org.hibernate:hibernate-commons-annotations:jar:3.2.0.Final:compile 

起初我以爲3.2.0.Final引用是原因,但進一步的研究使其聽起來像它只是一個空的佔位符神器遺留的緣故。

我對Spring的依賴,我認爲是問題,但是,但是我不知道要解決什麼,或者如果我在看另一個紅鯡魚:

[INFO] [snip MyProjectName] 
[INFO] +- org.springframework:org.springframework.orm:jar:3.1.1.RELEASE:compile 
[INFO] | +- org.springframework:org.springframework.jdbc:jar:3.1.1.RELEASE:compile 
[INFO] | \- org.springframework:org.springframework.transaction:jar:3.1.1.RELEASE:compile 
[INFO] +- org.springframework:org.springframework.web:jar:3.1.1.RELEASE:compile 
[INFO] | \- org.springframework:org.springframework.aop:jar:3.1.1.RELEASE:compile 
[INFO] +- org.springframework:org.springframework.beans:jar:3.1.1.RELEASE:compile 
[INFO] | \- org.springframework:org.springframework.asm:jar:3.1.1.RELEASE:compile 
[INFO] +- org.springframework:org.springframework.context:jar:3.1.1.RELEASE:compile 
[INFO] | \- org.springframework:org.springframework.expression:jar:3.1.1.RELEASE:compile 
[INFO] +- org.springframework:org.springframework.core:jar:3.1.1.RELEASE:compile 
[INFO] \- org.apache.struts:struts2-spring-plugin:jar:2.2.3.1:compile 
[INFO] +- org.springframework:spring-beans:jar:2.5.6:compile 
[INFO] +- org.springframework:spring-core:jar:2.5.6:compile 
[INFO] +- org.springframework:spring-context:jar:2.5.6:compile 
[INFO] \- org.springframework:spring-web:jar:2.5.6:compile 

所以我覺得我看到了兩個可能的問題

  1. Struts2的彈簧,插件在老版本的春天拉 - 不過到目前爲止,我發現每個Web資源說,Struts2的彈簧,插件應該隨着春天的新版本。我在這裏做錯了什麼?我還沒有找到其他更新版本的插件來嘗試。

  2. 爲了找到新版本的spring,我不得不切換到ERB spring版本庫,所以artifactIds在兩個版本中都不匹配 - 直接的spring依賴是org.springframework:org.springframe。 {component},而間接是org.springframework:spring- {component}。這是一個問題嗎?我試圖在ERB spring repository中尋找struts2-spring-plugin,但是他們沒有託管它,所以我懷疑我能找到與artifactId命名方案相匹配的版本。

我列出了下一個pom的完整依賴部分,以防上述情況都是紅鯡魚。我應該使用其他工具/調查來發現問題嗎?謝謝。

<dependencies> 
    <dependency> 
    <groupId>junit</groupId> 
    <artifactId>junit</artifactId> 
    <version>4.4</version> 
    <scope>test</scope> 
    </dependency> 
    <dependency> 
    <groupId>org.easymock</groupId> 
    <artifactId>easymockclassextension</artifactId> 
    <version>3.0</version> 
    <scope>test</scope> 
    </dependency> 
    <dependency> 
    <groupId>com.google.guava</groupId> 
    <artifactId>guava</artifactId> 
    <version>r07</version> 
    </dependency> 
    <dependency> 
    <groupId>javax.mail</groupId> 
<artifactId>mail</artifactId> 
    <version>1.4.1</version> 
    </dependency> 
    <dependency> 
    <groupId>org.dbunit</groupId> 
    <artifactId>dbunit</artifactId> 
    <version>2.2</version> 
    <scope>test</scope> 
    </dependency> 
    <dependency> 
    <groupId>org.hibernate</groupId> 
    <artifactId>hibernate-entitymanager</artifactId> 
    <version>3.5.6-Final</version> 
    </dependency> 
    <dependency> 
    <groupId>postgresql</groupId> 
    <artifactId>postgresql</artifactId> 
    <version>9.1-901.jdbc3</version> 
    </dependency> 
    <dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>org.springframework.orm</artifactId> 
    <version>3.1.1.RELEASE</version> 
    </dependency> 
    <dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>org.springframework.web</artifactId> 
    <version>3.1.1.RELEASE</version> 
    </dependency> 
    <dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>org.springframework.beans</artifactId> 
    <version>3.1.1.RELEASE</version> 
    </dependency> 
    <dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>org.springframework.context</artifactId> 
    <version>3.1.1.RELEASE</version> 
    </dependency> 
    <dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>org.springframework.core</artifactId> 
    <version>3.1.1.RELEASE</version> 
    </dependency> 
    <dependency> 
    <groupId>log4j</groupId> 
    <artifactId>log4j</artifactId> 
    <version>1.2.14</version> 
    </dependency> 
    <dependency> 
    <groupId>commons-collections</groupId> 
    <artifactId>commons-collections</artifactId> 
    <version>3.1</version> 
    </dependency> 
    <dependency> 
    <groupId>org.apache.struts</groupId> 
    <artifactId>struts2-spring-plugin</artifactId> 
    <version>2.2.3.1</version> 
    </dependency> 
    <dependency> 
    <groupId>org.apache.struts</groupId> 
    <artifactId>struts2-core</artifactId> 
    <version>2.2.3.1</version> 
    </dependency> 
    <dependency> 
    <groupId>org.apache.struts</groupId> 
    <artifactId>struts2-config-browser-plugin</artifactId> 
    <version>2.2.3.1</version> 
    </dependency> 
    <dependency> 
    <groupId>org.apache.struts</groupId> 
    <artifactId>struts2-json-plugin</artifactId> 
    <version>2.2.3.1</version> 
</dependency> 
<dependency> 
    <groupId>com.jgeppert.struts2.jquery</groupId> 
    <artifactId>struts2-jquery-plugin</artifactId> 
    <version>2.4.1</version> 
</dependency> 
<dependency> 
    <groupId>com.jgeppert.struts2.jquery</groupId> 
    <artifactId>struts2-jquery-grid-plugin</artifactId> 
    <version>2.4.1</version> 
</dependency> 
<dependency> 
    <groupId>com.jgeppert.struts2.jquery</groupId> 
    <artifactId>struts2-jquery-richtext-plugin</artifactId> 
    <version>2.4.1</version> 
</dependency> 
<dependency> 
    <groupId>org.freemarker</groupId> 
    <artifactId>freemarker</artifactId> 
    <version>2.3.16</version> 
</dependency> 
<dependency> 
    <groupId>org.apache.struts</groupId> 
    <artifactId>struts2-sitemesh-plugin</artifactId> 
    <version>2.2.1</version> 
</dependency> 
<dependency> 
    <groupId>org.apache.struts</groupId> 
    <artifactId>struts2-convention-plugin</artifactId> 
    <version>2.2.1</version> 
</dependency>  
<dependency> 
    <groupId>javax.servlet</groupId> 
    <artifactId>servlet-api</artifactId> 
    <version>2.4</version> 
    <scope>provided</scope> 
</dependency> 
<dependency> 
    <groupId>taglibs</groupId> 
    <artifactId>standard</artifactId> 
    <version>1.1.2</version> 
</dependency> 
<dependency> 
    <groupId>javax.servlet</groupId> 
    <artifactId>jstl</artifactId> 
    <version>1.1.2</version> 
</dependency> 
<dependency> 
    <groupId>concurrent</groupId> 
    <artifactId>concurrent</artifactId> 
    <version>1.3.4</version> 
</dependency> 
<dependency> 
    <groupId>com.itextpdf</groupId> 
    <artifactId>itextpdf</artifactId> 
    <version>5.0.4</version> 
</dependency> 
</dependencies> 

回答

1

如果您打算使用不同於它需要的版本,則需要從struts 2 spring插件中排除spring依賴項。