0

I am trying to deploy struts+spring+hibernate app on tomcat server, but there occurs some error with struts configuration, namely in struts.xml I am using a bean editEmployeeAction defined on spring.xml, but while deploying the app, the tomcat failed to load the action [not found action]

please help me to solve the problem!

spring.xml

   ...
   <!-- This bean has been referred fron struts.xml file; So type it correctly; -->
   <!-- Make scope prototype; This is really important. -->
   <bean id="editEmployeeAction" class="me.modernpage.controller.EditEmployeeAction" 
    scope="prototype">
    <property name="employeeManager">
        <ref bean="employeeManager"/>
    </property>
  </bean>   

  <bean id="employeeDAO" class="me.modernpage.dao.EmployeeDAOImpl">
    <property name="sessionFactory">
        <ref bean="sessionFactory"/>
    </property>
  </bean>
   <bean id="employeeManager" class="me.modernpage.service.EmployeeManagerImpl">
    <property name="employeeDAO">
        <ref bean="employeeDAO"/>
    </property>
   </bean> 
   ...

struts.xml located on src/

<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.custom.i18n.resources" value="messages" />
<constant name="struts.enable.SlachesInActionNames" value="true" />

<package name="default" namespace="" extends="struts-default">
    <!-- Two things to Notice: 
         1) class is set to 'editEmployeeAction' which is bean defined by Spring context
         2) We have given the method to be called here as well; -->
    
    <action name="list" class="editEmployeeAction" method="listEmployees">
        <result>/view/editEmployeeList.jsp</result>
    </action>
    
    <action name="add" class="editEmployeeAction" method="addEmployee">
        <result type="redirect">/list</result>
    </action>
    
    <action name="delete/*" class="editEmployeeAction" method="deleteEmployee">
        <param name="employee.id">{1}</param>
        <result type="redirect">/list</result>
    </action>
    <action name="*" class="editEmployeeAction" method="listEmployees">
        <result>/view/editEmployeeList.jsp</result>
    </action>
</package>
</struts>

here, as you can see the value of 'class' is ediEmployeeList bean, then i think the tomcat can't find this bean?!

error:

23:06:57,021 ERROR Dispatcher:42 - Dispatcher initialization failed

Unable to load configuration. - action - file:/home/yusuf/tomcat/apache-tomcat-9.0.24/web/Spring_Struts_Hibernate/WEB-INF/classes/struts.xml:17:73 at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70) at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:978) at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:446) at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:490) 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:270) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:251) at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:102) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4533) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5172) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:932) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.startup.Catalina.start(Catalina.java:633) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:344) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:475) Caused by: Action class [editEmployeeAction] not found - action - file:/home/yusuf/tomcat/apache-tomcat-9.0.24/web/Spring_Struts_Hibernate/WEB-INF/classes/struts.xml:17:73 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:486) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:429) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:556) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:295) at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112) at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:264) at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67) ... 38 more

Roman C
  • 49,761
  • 33
  • 66
  • 176
Yusuf
  • 31
  • 2
  • 7
  • Kindly resolve this first: `Caused by: Action class [editEmployeeAction] not found` – Jayr Dec 09 '20 at 18:51
  • I tried to discover all the causes of this statement, didn't find a clue – Yusuf Dec 09 '20 at 19:09
  • Can you add more details to the question such as web.xml – Roman C Dec 10 '20 at 06:04
  • @RomanC no problem with web.xml, i solved the problem by putting the struts2-spring-plugin.jar file on the class path, thanks bro for the attention – Yusuf Dec 10 '20 at 06:08

1 Answers1

0

finally, i realized the cause of the problem , the project lacks struts-spring-plugin library to link struts and spring each other.

strust2-spring-plugin

Yusuf
  • 31
  • 2
  • 7