NoSuchMethodError:在Apache Tomcat 8上部署Struts 2应用程序时出现错误

56lgkhnf  于 5个月前  发布在  Apache
关注(0)|答案(4)|浏览(60)

应用程序在本地计算机上运行正常。
在服务器上,我有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:

字符串

a0x5cqrl

a0x5cqrl1#

jar存在于应用程序的lib目录中
哪个jar?因为我猜您指的是struts2-core-2.3.24.1.jar,它包含您正在使用的StrutsPrepareAndExecuteFilter,但您还需要xwork-core-2.3.24.1.jar(或您的版本),它包含过滤器引用的其他方法

slmsl1lt

slmsl1lt2#

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

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

字符串

ar5n3qh5

ar5n3qh53#

com.opensymphony.xwork2.config.ConfigurationManagerxwork*.jar中,它没有addConfigurationProvider()方法。如果您的应用程序
在本地计算机上运行正常
然后你在服务器库的某个地方有另一个同名的jar文件。但是这个文件有不同的版本。确保你对struts2-core*.jarxwork-core*.jar有相同的版本。
这是一个链接,你可以下载所有需要的库。
将必要的库放到WEB-INF/lib中并清理服务器类路径。

kxkpmulp

kxkpmulp4#

因此,当我切换到tomcat7而不是tomcat8时,应用程序工作正常。

相关问题