启动错误:java.lang.IncompatibleClassChangeError:org / apache / struts2 / convention / DefaultClassFinder $ InfoBuildingVisitor

时间:2017-07-03 15:52:35

标签: struts2 struts2-convention-plugin

我有一个Struts2应用程序,最初是基于XML的,但现在我第一次引入了基于Annotation的操作,并且应用程序在启动时破坏了。

给定以下Action映射,在启动应用程序时,我收到错误

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)

这里有一个类似的问题,但没有人回应, 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的瓷砖-插件-2.5.10.1.jar
  • XWork的核 - 2.1.6.jar

更新:我认为Convention-Plugin-JAR 2.3.14.3与其他2.5.10.1版本不兼容,所以我下载了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 Version 5.1 JARs。

2 个答案:

答案 0 :(得分:1)

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

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

答案 1 :(得分:0)

Struts2使用ASM 5x作为Convention插件。检查类路径并确保您有适当版本的ASM jar。