调试java.lang.IncompatibleClassChangeError:实现类错误(Spring / Hibernate / Struts)

时间:2012-02-19 00:22:09

标签: spring maven struts2 struts2-spring-plugin

我最近开始尝试升级几年过时的Struts2 / Spring / Hibernate应用程序的某些依赖项 - 主要是尝试选择@Enumerated注释。 POM越来越清洁,这是一个很好的副作用

所有代码编译并且单元测试通过,但服务器不会以

开头
  

“引起:java.lang.IncompatibleClassChangeError:实现类”

错误消息。

我已经跟踪了几个讨论跟踪依赖项中版本不匹配的线程 - 人们似乎经常会得到两个版本的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参考是原因,但进一步的研究使它听起来像是一个空的占位符神器。

我认为我的春天依赖性是问题,但我不知道该修复什么,或者我是否正在寻找另一种红鲱鱼:

[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-spring-plugin正在引入旧版本的spring - 但是到目前为止我发现的每个web资源都说struts2-spring-plugin应该适用于新版本的spring。我在这里做错了吗?我还没有找到其他较新版本的插件。

  2. 我不得不切换到ERB spring存储库以便找到spring的新版本,因此artifactIds在两者之间不匹配 - 直接的spring依赖项是org.springframework:org.springframe 。{component}而间接是org.springframework:spring- {component}。这是一个问题吗?我试图在ERB spring存储库中查找struts2-spring-plugin,但它们没有托管它,所以我怀疑我能找到一个与artifactId命名方案匹配的版本。

  3. 我正在列出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 个答案:

答案 0 :(得分:1)

如果你打算使用不同于它的版本,你需要从struts 2 spring插件中排除spring依赖项。