简体   繁体   中英

NoSuchMethodError: ConfigurationManager.addConfigurationProvider while deploying Struts 2 application on Apache Tomcat 8

The application runs fine on the local machine.

On the server I have JDK-1.7 and Tomcat8. It is giving me the below error in localhost logs. The jar exists in the lib directory of the application.

SEVERE [http-nio-8080-exec-5] org.apache.catalina.core.StandardContext.filterStart Exception starting filter struts2
 java.lang.NoSuchMethodError: com.opensymphony.xwork2.config.ConfigurationManager.addConfigurationProvider(Lcom/opensymphony/xwork2/config/ConfigurationProvider;)V
        at org.apache.struts2.dispatcher.Dispatcher.init_DefaultProperties(Dispatcher.java:296)
        at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:396)
        at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
        at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:48)
        at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
        at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
        at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
        at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4659)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContex:

The jar exists in the lib directory of the application

Which Jar ? Because I guess you're referring to the struts2-core-2.3.24.1.jar , that contains the StrutsPrepareAndExecuteFilter you're using, but you also need the xwork-core-2.3.24.1.jar (or whatever your version is), that contains the other methods the filter refers to

似乎 jar 版本不匹配,因为它能够在该 jar 中找到类文件,但不能在类 ConfigurationManager 中找到具有以下签名的方法

com.opensymphony.xwork2.config.ConfigurationManager.addConfigurationProvider (Lcom/opensymphony/xwork2/config/ConfigurationProvider;)

com.opensymphony.xwork2.config.ConfigurationManager is in the xwork*.jar and it doesn't have a method addConfigurationProvider() . If your app

runs fine on local machine

then you have another jar with the same name file somewhere on the server lib. But this file has a different version. Make sure you have the same version for struts2-core*.jar and xwork-core*.jar .

This is the link where you can download all required libraries.

Put necessary libraries to the WEB-INF/lib and clean up the server classpath.

所以当我切换到 tomcat7 而不是 tomcat8 时,应用程序运行良好。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM