youssef youssef - 5 months ago 24
Linux Question

can't change or add action in struts2

i am having a problem with struts i've been working with struts with more than 4 month now
the problem is when i add a new action i get this:

enter image description here

the previous actions work fine but when i modify the name of the action in struts.xml i get the error i mention above.
so for example i have the following code in struts.xml

<action name="test1" class="com.onda.beans.AfficheVolList">
<result name="success">table_vols_test_css.jsp</result>
<result name="fail">admin.jsp</result>
</action>


when i enter http://localhost:8080/Myproject/test1 it works fine
but after i change the name of the action

<action name="test2" class="com.onda.beans.AfficheVolList">
<result name="success">table_vols_test_css.jsp</result>
<result name="fail">admin.jsp</result>
</action>


and i try to enter localhost:8080/Myproject/test2
i got the error in the previous image it doesn't even take me to admin.jsp

i tried to clean the server and clean work directory but nothing work i even changed the server it works for the first time but after i change the name of the action it doesn't work
here is the log

`Jun 01, 2016 12:24:58 PM org.apache.struts2.dispatcher.Dispatcher error
SEVERE: Could not find action or result
/Onda_vol/vols2
There is no Action mapped for namespace [/] and action name [vols2] associated with context path [/Onda_vol]. - [unknown location]
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:37)
at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:554)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:81)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)`


thank you for taking time to answer my question i really appreciate it

Answer

This is probably a problem in your Apache Tomcat server configuration.

Your struts.xml looks perfectly fine and there is no reason changing the name would break the action.

Here's a few things you could consider doing and that might solve your problem:

  • Restart Tomcat

Depending on your linux distro and Tomcat version, this might differ.

sudo service tomcat7 restart
  • Restart your computer
  • Delete and reinstall Tomcat

I hope this helps.

Comments