1

I am having this issue in running my struts application. This is my web.xml file having the filter class and name and server responds saying it was not able to load class

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>Struts2starter</display-name>
  <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>   
</web-app>

Exception:

SEVERE: Dispatcher initialization failed
Unable to load configuration. - bean - jar:file:/C:/Users/My/newworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Struts2starter/WEB-INF/lib/struts2-gxp-plugin-2.3.16.1.jar!/struts-plugin.xml:8:162
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:445)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:489)
    at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:193)
    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:4809)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5485)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: Unable to load bean: type:org.apache.struts2.views.gxp.inject.InjectedObjectContainer class:org.apache.struts2.views.gxp.inject.InjectedObjectContainer - bean - jar:file:/C:/Users/My/newworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Struts2starter/WEB-INF/lib/struts2-gxp-plugin-2.3.16.1.jar!/struts-plugin.xml:8:162
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:245)
    at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:102)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:234)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
    ... 16 more
Caused by: java.lang.ClassNotFoundException: org.apache.struts2.views.gxp.inject.InjectedObjectContainer
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1718)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569)
    at com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:152)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:216)
    ... 19 more
leonbloy
  • 73,180
  • 20
  • 142
  • 190
user3456554
  • 11
  • 1
  • 2

3 Answers3

4

I was facing the same problem too with struts 2.3.20. I solved it by removing all the unnecessary jars using only these nine jars that are:

commons-fileupload-1.3.1jar,
commons-io-2.2.jar,
commons-lang3-3.2.jar,
commons-logging-1.1.3.jar,
freemarker-2.3.19.jar,
javassist-3.11.0.GA.jar,
ognl-3.0.6.jar,
struts2-core-2.3.20.jar,
xwork-core-2.3.20.jar"

Shiva Agrawal
  • 161
  • 2
  • 9
  • 1
    Exactly this was the issue for me. I got this issue by just following the struts2 tutorial given in the tutorialspoint http://www.tutorialspoint.com/struts_2/struts2_tutorial.pdf – Janaka Priyadarshana Feb 09 '15 at 10:49
0

Remove unused plugins like struts2-gxp-plugin-2.3.16.1.jar from /WEB-INF/lib. Also org.apache.struts2.dispatcher.FilterDispatcher is deprecated in Struts 2.3.16.1. See a Simple Example of configuring web.xml for the Struts2 framework by adding filter and filter-mapping tags.

Roman C
  • 49,761
  • 33
  • 66
  • 176
0

More detail for the above answers: Assuming you are using eclipse, it's not enough to remove the extraneous files from the .../WEB-INF/lib directory. If you make changes to your project, eclipse will redeploy the original libraries (jar files). To remove them from your build path in eclipse so they don't get redeployed, go to Window >> Preferences >> Java >> Build Path >> User Libraries, and highlight and remove the unwanted jars. (And of course remove from WEB-INF/lib if applicable).

jhinx
  • 1
  • 1