Debugging java.lang.IncompatibleClassChangeError: Implementing class errors (Spring/Hibernate/Struts)

妖精的绣舞 提交于 2019-12-08 07:44:51

问题


I recently began trying to upgrade some dependencies of a Struts2/Spring/Hibernate application that were several years out of date -- primarily to try to pick up the @Enumerated annotation. The POM is getting cleaner along the way, which is a nice side effect

All the code compiles and the unit tests pass, but the server won't start with the

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

error message.

I've followed several threads that talk about tracking down version mismatches in dependencies -- people often seem to get two version of hibernate. I don't think I have that problem:

[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

At first I thought that the 3.2.0.Final reference was the cause, but further research make its sound like its just an empty placeholder artifact for legacy sake.

My spring dependencies I think are the problem, however, but I'm not sure what to fix, or if I'm looking at another red herring:

[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

so I think I see two possible problems

  1. the struts2-spring-plugin is pulling in old versions of spring -- however every web resource I've found so far says that the struts2-spring-plugin should work with new versions of spring. Am I doing something wrong here? I haven't found other newer versions of the plugin to try.

  2. I had to switch to the ERB spring repository in order to even find the new versions of spring, so the artifactIds aren't matching across the two -- the direct spring dependencies are org.springframework:org.springframe.{component} while the indirect are org.springframework:spring-{component}. Is this a problem? I tried looking for the struts2-spring-plugin in the ERB spring repository, but they don't host it, so I doubt I can find a version that matches on the artifactId naming scheme.

I'm listing the complete dependency section of the pom next, in case both of the above are red herrings. Are there other tools/investigations I should be using to figure out the problem? Thank you.

<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:


You need to exclude the spring dependencies from the struts 2 spring plugin if you're going to use a different version than it requires.



来源:https://stackoverflow.com/questions/9345488/debugging-java-lang-incompatibleclasschangeerror-implementing-class-errors-spr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!