调试java.lang.IncompatibleClassChangeError:实现类错误(Spring/Hibernate/Struts) [英] Debugging java.lang.IncompatibleClassChangeError: Implementing class errors (Spring/Hibernate/Struts)

查看:86
本文介绍了调试java.lang.IncompatibleClassChangeError:实现类错误(Spring/Hibernate/Struts)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始尝试升级Struts2/Spring/Hibernate应用程序的某些依赖关系,这些依赖关系已经过时了几年-主要是为了尝试使用@Enumerated批注. POM一路变得越来越干净,这是一个很好的副作用

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

由于:java.lang.IncompatibleClassChangeError:实现类"

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

错误消息.

我遵循了几条有关追踪依赖关系中版本不匹配的主题-人们似乎常常会获得两个版本的休眠状态.我认为我没有这个问题:

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

起初我以为3.2.0.Final引用是其中的原因,但是进一步的研究使其听起来像是出于遗留目的只是一个空的占位符.

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.

不过,我认为我的spring依赖关系是问题所在,但是我不确定要解决什么,或者我是否正在寻找其他红色鲱鱼:

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. struts2-spring-plugin引入了旧版本的spring-但是,到目前为止,我发现的每个Web资源都说struts2-spring-plugin应该与spring的新版本一起使用.我在这里做错什么了吗?我没有找到其他较新版本的插件可以尝试.

  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.

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

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.

如果上面两个都是红色鲱鱼,我接下来将列出pom的完整依赖项部分.我应该使用其他工具/调查来解决问题吗?谢谢.

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>

推荐答案

如果要使用与所需版本不同的版本,则需要从struts 2 spring插件中排除spring依赖项.

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.

这篇关于调试java.lang.IncompatibleClassChangeError:实现类错误(Spring/Hibernate/Struts)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆