IncompatibleClassChangeError

IncompatibleClassChangeError

本文介绍了启动错误:java.lang.IncompatibleClassChangeError:org/apache/struts2/convention/DefaultClassFinder $ InfoBuildingVisitor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Struts2应用程序,该应用程序最初是基于XML的,但是现在我第一次引入了一个基于Annotation的操作,该应用程序在启动时就崩溃了.

I have a Struts2 application, originally XML-based, but now for the first time I introduced an Annotation-based action, and the application broke on startup.

鉴于以下操作映射,在应用程序启动时,我得到了错误

Given the following Action mapping, on startup of the application, I get the error

java.lang.InstantiationError: com.opensymphony.xwork2.util.finder.ClassFinder
    at org.apache.struts2.convention.PackageBasedActionConfigBuilder.findActions(PackageBasedActionConfigBuilder.java:390)
    at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.java:347)
    at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:53)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:199)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
    at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:906)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:445)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:486)
    at org.apache.struts2.dispatcher.InitOperations.initDispatcher(InitOperations.java:75)
    at org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:63)
    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)

这里有一个类似的问题,但是没有人回答,问题出现Struts2过滤器异常

There was a similar question here, but no one responded,Issue with Struts2 Filter Exception

已使用的库:

  • struts2-convention-plugin-2.3.14.3.jar
  • struts2-core-2.5.10.1.jar
  • struts2-json-plugin-2.5.10.1.jar
  • struts2-spring-plugin-2.5.10.1.jar
  • struts2-tiles-plugin-2.5.10.1.jar
  • xwork-core-2.1.6.jar

更新:我认为Convention-Plugin-JAR 2.3.14.3与其他2.5.10.1版本不兼容,所以我下载了struts2-convention-plugin-2.5.10.1.jar

Update: I thought the Convention-Plugin-JAR 2.3.14.3 was incompatible with the other 2.5.10.1 ones, so I downloaded: struts2-convention-plugin-2.5.10.1.jar

现在开始启动

java.lang.IncompatibleClassChangeError: org/apache/struts2/convention/DefaultClassFinder$InfoBuildingVisitor
    at org.apache.struts2.convention.DefaultClassFinder.readClassDef(DefaultClassFinder.java:459) ~[struts2-convention-plugin-2.5.10.1.jar:2.5.10.1]
    at org.apache.struts2.convention.DefaultClassFinder.<init>(DefaultClassFinder.java:90) [struts2-convention-plugin-2.5.10.1.jar:2.5.10.1]
    at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildClassFinder(PackageBasedActionConfigBuilder.java:397) [struts2-convention-plugin-2.5.10.1.jar:2.5.10.1]
    at org.apache.struts2.convention.PackageBasedActionConfigBuilder.findActions(PackageBasedActionConfigBuilder.java:379) [struts2-convention-plugin-2.5.10.1.jar:2.5.10.1]
    at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.java:335) [struts2-convention-plugin-2.5.10.1.jar:2.5.10.1]
    at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:53) [struts2-convention-plugin-2.5.10.1.jar:2.5.10.1]
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:199) [struts2-core-2.5.10.1.jar:2.5.10.1]

解决方案解决方案是添加ASM 5.x JAR,它是Struts-Convention JAR的批注依赖项.我们正在使用ASM 3.3.我添加了ASM-Core,-Common,-Tree版本5.1 JAR.

推荐答案

struts2-convention插件2.5.10.1具有编译依赖性

struts2-convention plugin 2.5.10.1 has compile dependencies

<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-lang3</artifactId>
    <version>3.4</version>
</dependency>
<dependency>
    <groupId>org.ow2.asm</groupId>
    <artifactId>asm</artifactId>
    <version>5.1</version>
</dependency>
<dependency>
    <groupId>org.ow2.asm</groupId>
    <artifactId>asm-commons</artifactId>
    <version>5.1</version>
</dependency>


注意:如果不需要asmasm-commons依赖项,则可以降级到Struts 2.5.5.


Note: if you don't need asm and asm-commons dependencies you can downgrade to Struts 2.5.5.

这篇关于启动错误:java.lang.IncompatibleClassChangeError:org/apache/struts2/convention/DefaultClassFinder $ InfoBuildingVisitor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 00:01