Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

com.opensymphony.xwork2.inject.DependencyException: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException

While deploying my war file I am getting the below exception:

SEVERE: Exception starting filter struts2
com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No mapping found for dependency [type=com.opensymphony.xwork2.ObjectFactory, name='default'] in public void com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.setObjectFactory(com.opensymphony.xwork2.ObjectFactory). - Class: com.opensymphony.xwork2.inject.ContainerImpl
File: ContainerImpl.java
Method: addInjectorsForMembers
Line: 144 - com/opensymphony/xwork2/inject/ContainerImpl.java:144:-1
        at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:501)
        at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
        at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
        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.addChildInternal(ContainerBase.java:901)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1073)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)
Caused by: com.opensymphony.xwork2.inject.DependencyException: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No mapping found for dependency [type=com.opensymphony.xwork2.ObjectFactory, name='default'] in public void com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.setObjectFactory(com.opensymphony.xwork2.ObjectFactory).
        at com.opensymphony.xwork2.inject.ContainerImpl.addInjectorsForMembers(ContainerImpl.java:144)
        at com.opensymphony.xwork2.inject.ContainerImpl.addInjectorsForMethods(ContainerImpl.java:113)
        at com.opensymphony.xwork2.inject.ContainerImpl.addInjectors(ContainerImpl.java:90)
        at com.opensymphony.xwork2.inject.ContainerImpl.addInjectors(ContainerImpl.java:86)
        at com.opensymphony.xwork2.inject.ContainerImpl$1.create(ContainerImpl.java:71)
        at com.opensymphony.xwork2.inject.ContainerImpl$1.create(ContainerImpl.java:67)
        at com.opensymphony.xwork2.inject.util.ReferenceCache$CallableCreate.call(ReferenceCache.java:150)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at com.opensymphony.xwork2.inject.util.ReferenceCache.internalCreate(ReferenceCache.java:76)
        at com.opensymphony.xwork2.inject.util.ReferenceCache.get(ReferenceCache.java:116)
        at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:490)
        at com.opensymphony.xwork2.inject.ContainerImpl$6.call(ContainerImpl.java:530)
        at com.opensymphony.xwork2.inject.ContainerImpl$6.call(ContainerImpl.java:528)
        at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:584)
        at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:528)
        at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:257)
        at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
        at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:445)
        at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:489)

I have included the struts-default.xml in init-param in web.xml as suggested by some posts.

Still it is not working!!

Am I missing anything?

web.xml is similar as below

<?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" 
   xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
   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>Struts 2</display-name>
   <welcome-file-list>
      <welcome-file>index.jsp</welcome-file>
   </welcome-file-list>
   <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>

struts.xml is similar as below

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
   "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
   "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" />
   <package name="helloworld" extends="struts-default">

      <action name="hello" 
            class="com.tutorialspoint.struts2.HelloWorldAction" 
            method="execute">
            <result name="success">/HelloWorld.jsp</result>
      </action>
   </package>
</struts>
like image 994
Priyaranjan Singh Avatar asked Dec 08 '25 20:12

Priyaranjan Singh


1 Answers

  1. Drop the FilterDispatcher that is deprecated, and set the new filter.
  2. Correct your DTDs: in web.xml you are mixing 2.5 with 3.0. All 2.5 or all 3.0 (or all 2.4, according to your application server specs). In struts.xml, it should be 2.3 unless you are using a really old version (and you should not).
  3. Make sure you have included all the required dependencies, each one only once, and all with the right versions.
like image 167
Andrea Ligios Avatar answered Dec 10 '25 09:12

Andrea Ligios



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!