TaherT
TaherT

Reputation: 1335

Struts2 on action button HTTP Status 404 - There is no Action mapped for namespace / and action name add

I m Newbie to Struts2 and I am following http://viralpatel.net/blogs/2010/01/tutorial-struts2-hibernate-example-eclipse.html to make Struts2 project but i m getting error : HTTP Status 404 - There is no Action mapped for namespace / and action name add. I am creating project in "Netbeans 6.8". URL pattern on which I am getting error http://localhost:8080/StrutsTest/add

My Log :

WARNING: No configuration found for the specified action: 'add' in namespace: ''. Form action defaulting to 'action' attribute's literal value.
WARNING: No configuration found for the specified action: 'add' in namespace: ''. Form action defaulting to 'action' attribute's literal value.
WARNING: Could not find action or result
There is no Action mapped for namespace / and action name add. - [unknown location]
        at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:178)
        at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
        at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
        at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47)
        at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:478)
        at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
        at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
        at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
        at java.lang.Thread.run(Thread.java:619)

Upvotes: 0

Views: 1721

Answers (2)

spaceofmiah
spaceofmiah

Reputation: 238

For those of you still having troubles resolving the above error. This is what i did that worked for me. Within the jsp page that is rendering the form, on the form tag, i just included the namespace of the package that the referred form action name is located, for example:

struts.xml ( this is just a fraction of my struts.xml config )

<package name="user" namespace="/user" extends="struts-default">
    <action name="update" class="actionbean.UserProfileUpdate">
        <result name="error">pages/error.jsp</result>       
        <result name="success" type="redirect">pages/profile.jsp</result>
    </action>
</package>

NOTE: the action name is update and it's within /user namespace.

profile.jsp --> This form generates above error

this code generates above error ( when i used it ), solely because i didn't include the namespace attribute

<form action="update" method="post">
    .....
    [ other codes ]
</form>

profile.jsp --> (this form runs as expected)

<form action="update" method="post" namespace="/user">
    .....
    [ other codes ]
</form>

please note: i'm not sure why this solution worked for me, reason is because i have several forms in my web app as at the time i'm providing this information, and i didn't have to do this in any other form except this update form.

vital information about my environment if needed

Product Version: NetBeans IDE 8.2 (Build 201705191307)

Updates: NetBeans IDE is updated to version NetBeans 8.2 Patch 2

Java: 1.8.0_161; Java HotSpot(TM) 64-Bit Server VM 25.161-b12

Strut: strut 2 core 2.3.15

Good luck with this.

Upvotes: 1

Umesh Awasthi
Umesh Awasthi

Reputation: 23587

Please copy your struts.xml file it will help to understand.what i can find from your log is that wither you have done wrong configuration in the xml file or you have defined an action in xml which is not yet defined

Upvotes: 0

Related Questions