Exception starting filter struts2 - tried adding JAR's, but same result

tempusfugit picture tempusfugit · Jun 13, 2013 · Viewed 12.6k times · Source

Here is the error I am getting:

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

List of JARs:

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

And my web.xml is like this:

<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>

I have tried lot of things after reading on this forum:

  1. Tried different versions of JAR.
  2. Manually deployed WAR into Tomcat.
  3. Placed the servlet-api JAR into the lib folder as well ( although it being present in the server lib).
  4. Read the Tomcat logs, found nothing different. ( Please let me know, I can paste those as well)

But none of them have helped. So, last resort, I am posting it here.

Answer

Andrea Ligios picture Andrea Ligios · Jun 14, 2013

Since you are using Struts 2.3,

FilterDispatcher is deprecated. You MUST use StrutsPrepareAndExecuteFilter (or its little brothers).

From the official documentation

Deprecated. Since Struts 2.1.3, use StrutsPrepareAndExecuteFilter instead or StrutsPrepareFilter and StrutsExecuteFilter if needing using the ActionContextCleanUp filter in addition to this one

change then this

<!-- Struts < 2.1.3 -->
<filter-class>
    org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>

to this:

<!-- Struts >= 2.1.3 and < 2.5 -->
<filter-class>
     org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>

Note that, from 2.5, it would be instead:

<!-- Struts >= 2.5 -->
<filter-class>
     org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
</filter-class>