IncompatibleClassChangeError:在struts 2.5.13中实现类

时间:2017-12-05 09:22:05

标签: java struts2

以下struts jar用于项目:

activation.jar,  asm-5.2.jar,  asm-commons-5.2.jar ,asm-tree-5.2.jar, commons-beanutils-1.9.2.jar , commons-collections-3.2.2.jar, commons-fileupload-1.3.3.jar ,  commons-io-2.5.jar , commons-lang-2.5.jar, commons-lang3-3.6.jar,  commons-logging-1.1.3.jar, commons-logging-api-1.1.jar , freemarker-2.3.23.jar,  javassist-3.20.0-GA.jar , javax.servlet.jar  ,log4j-api-2.8.2.jar mail.jar , ognl-3.1.15.jar, struts2-convention-plugin-2.5.13.jar , struts2-core-2.5.13.jar,  struts2-rest-plugin-2.5.13.jar ,  xstream-1.4.10.jar,  xwork-core-2.3.34.jar

还在系统上安装了tomcat 8.5和java 8.

我在启动后收到以下错误,任何人都有任何想法!

04-Dec-2017 11:17:29.066 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.filterStart Exception starting filter [struts2]
Unable to load configuration. - bean - jar:file:/apache-tomcat-8.5.23/webapps/WebTool/WEB-INF/lib/struts2-core-2.5.13.jar!/struts-default.xml:137:154
        at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:512)
        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:285)
        at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:266)
        at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
        at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4591)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5233)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1144)
        at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1878)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
    Caused by: Unable to load bean: type:com.opensymphony.xwork2.TextProviderFactory class:com.opensymphony.xwork2.StrutsTextProviderFactory - bean - jar:file:/apache-tomcat-8.5.23/webapps/WebTool/WEB-INF/lib/struts2-core-2.5.13.jar!/struts-default.xml:137:154
        at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:247)
        at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:98)
        at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:240)
        at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
        ... 21 more
Caused by: java.lang.IncompatibleClassChangeError: Implementing class
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2283)
        at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:811)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1260)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
        at com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:144)
        at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:218)
        ... 24 more

Any help will be appreciated.

这是我的web.xml结构:

我已将过滤器调度程序更新为最新语句

org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>WebTool</display-name>
  <welcome-file-list>
    <welcome-file>Home.html</welcome-file>
  </welcome-file-list>

  <resource-ref>
      <description>DB Connection</description>
      <res-ref-name>jdbc/WEBTOOLDB</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
  </resource-ref>

    <filter>
      <filter-name>struts2</filter-name>
      <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
      <init-param>
            <param-name>actionPackages</param-name>
            <param-value>com.webtool.ktt.servlet</param-value>
      </init-param>
  </filter>

  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

</web-app>

1 个答案:

答案 0 :(得分:1)

遇到同样的问题。结果是由于struts2-core(v2.5.14.1)和xwork-core(2.3.34)都是依赖项。

struts2-core.jar,因为v2.5包含TextProviderFactory作为接口,但xwork-core将同一类的旧版本作为真正的类。

删除xwork-core依赖项解决了我的问题。