最近在配置strut2的时候老是出现这个问题:
2013-8-18 15:14:59 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter struts2
java.lang.NoSuchMethodError: com.opensymphony.xwork2.config.ConfigurationManager.addContainerProvider(Lcom/opensymphony/xwork2/config/ContainerProvider;)V
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.ng.InitOperations.initDispatcher(InitOperations.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter.init(StrutsPrepareFilter.java:50)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3693)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4340)
at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1105)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1203)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Thread.java:619)
2013-8-18 15:14:59 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2013-8-18 15:14:59 org.apache.catalina.core.StandardContext start
严重: Context [/struts] startup failed due to previous errors
这个主要是这个类ConfigurationManager的这个方法addContainerProvider 找不到
首先:看看有没有导入Struts2相应的jar包,是否齐全。最少要导入五个基本包:
commons-logging-api-1.1.jar
freemarker-2.3.8.jar
ognl-2.6.11.jar
struts2-core-2.0.12.jar
xwork-2.0.6.jar
(我出现那异常的原因是由于同时导入了xwork-2.0.6.jar和xwork-2.1.2.jar)
如果该包含的jar包都引入了,再看,配置文件web.xml是否配置正确,
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
以下是2.1以前配置的
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>*.do</url-pattern>
</filter-mapping>
如果以上两步都没有问题,那估计就是环境问题了,在开发中,环境问题是麻烦的事,检查你用的部署服务器(Tomcat或weblogic等)、IDE的版本(eclipse或者myEclipse),以及Struts2的版本...