以下是我遇到的错误:
SEVERE: Exception starting filter struts2
java.lang.NoClassDefFoundError: com/opensymphony/xwork2/config/FileManagerProvider
at org.apache.struts2.dispatcher.Dispatcher.init_FileManager(Dispatcher.java:336)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:465)
at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:193)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:424)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4072)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4726)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.ClassNotFoundException: com.opensymphony.xwork2.config.FileManagerProvider
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
... 30 more
JAR清单:
antlr-2.7.6.jar
commons-beanutils-1.8.3.jar
commons-collections-3.2.1.jar
commons-digester-2.1.jar
commons-fileupload-1.3.jar
commons-logging-1.1.1.jar
dom4j-1.6.1.jar
ejb3-persistence-1.0.2.GA.jar
freemarker-2.3.16.jar
hibernate-annotations-3.2.1.ga.jar
hibernate-commons-annotations-3.3.0.ga.jar
hibernate-core-4.2.1.Final.jar
hsqldb-2.0.0.jar
javassist-3.12.1.GA.jar
jta-1.1.jar
log4j-1.2.15.jar
mysql-connector-java-5.1.21.jar
ognl-2.7.3.jar
slf4j-api-1.6.1.jar
slf4j-log4j12-1.7.5.jar
struts2-core-2.3.14.3.jar
xwork-2.1.3.jar
我的web.xml是这样的:
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
在这个论坛上阅读后我尝试了很多东西:
但他们都没有帮助。所以,不得已,我在这里发帖。
答案 0 :(得分:6)
因为您使用的是Struts 2.3,
不推荐使用FilterDispatcher 。你必须使用StrutsPrepareAndExecuteFilter(或它的小兄弟)。
From the official documentation
<强>已过时即可。 自Struts 2.1.3起,使用 StrutsPrepareAndExecuteFilter 或 StrutsPrepareFilter 和 StrutsExecuteFilter ,如果需要使用ActionContextCleanUp过滤器
然后改变这个
<!-- Struts < 2.1.3 -->
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
到此:
<!-- Struts >= 2.1.3 and < 2.5 -->
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
请注意,从2.5开始,它将改为:
<!-- Struts >= 2.5 -->
<filter-class>
org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
</filter-class>