NoSuchMethodError:在 Apache Tomcat 8 上部署 Struts 2 应用程序时出现 ConfigurationManager.addConfigurationProvider

问题描述 投票:0回答:4

应用程序在本地计算机上运行良好。

在服务器上,我有 JDK-1.7 和 Tomcat 8。它在

localhost
日志中给出以下错误。该 jar 存在于应用程序的
lib
目录中。

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:
java tomcat struts2
4个回答
0
投票

该 jar 存在于应用程序的 lib 目录中

哪个罐子?因为我猜您指的是

struts2-core-2.3.24.1.jar
,其中包含您正在使用的 StrutsPrepareAndExecuteFilter,但您还需要
xwork-core-2.3.24.1.jar
(或无论您的版本是什么),其中包含过滤器引用的其他方法


0
投票

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

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

0
投票

com.opensymphony.xwork2.config.ConfigurationManager
位于
xwork*.jar
中,并且它没有方法
addConfigurationProvider()
。如果您的应用程序

在本地机器上运行良好

然后你在服务器库的某处有另一个具有相同名称文件的 jar。但这个文件有不同的版本。确保

struts2-core*.jar
xwork-core*.jar
具有相同的版本。

您可以通过此链接下载所有必需的库。

将必要的库放入

WEB-INF/lib
并清理服务器类路径。


0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.