1

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.

Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
tempusfugit
  • 437
  • 1
  • 3
  • 14
  • 1
    Use the same version of `xwork-core` jar as the `struts2-core` jar. – Aleksandr M Jun 13 '13 at 20:48
  • Yep. You can't arbitrarily mix-and-match library versions--that's why we use tools like Maven. I don't understand why you'd randomly add a servlet-api jar to your web app: besides that you *must* not provide your own, what in the error message would lead you to believe anything other than either (a) the referenced class is missing, or (b) one of its dependencies is missing? – Dave Newton Jun 13 '13 at 21:19
  • Thank you Aleksandr M. I matched the struts and xwork and it is working now. – tempusfugit Jun 14 '13 at 13:45
  • Dave Newton - I know arbitrarily mixing-match is not the way. But after trying a lot, nothing was working, so I tried it that way too. As far as servlet-api, I did that after reading in one of the posts. Thank you – tempusfugit Jun 14 '13 at 13:49

1 Answers1

6

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>
Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
  • 1
    Thanks Andrea. :D I did following changes: 1. Changed the filter-class to StrutsPrepareAndExecuteFilter. 2. Matched the versions of xwork (2.1.6) and struts (2.1.8.1) . stackoverflow is awesome! – tempusfugit Jun 14 '13 at 13:45
  • This has now (as of 2.5) changed to org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter. I've just used this tonight on struts2-core-2.5.8.jar. If it looks the same, the .ng. bit is missing. – Paul Uszak Jan 18 '17 at 01:03
  • @PaulUszak I knew, but have not updated all the answers yet. I've edited this now, thanks for the comment – Andrea Ligios Jan 18 '17 at 08:31