File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts2 namespace url problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 namespace url problem" Watch "Struts2 namespace url problem" New topic
Author

Struts2 namespace url problem

Sagar Kale
Ranch Hand

Joined: May 02, 2008
Posts: 188
Hi All,


I am new to struts2.


I have created HelloWorld action.

Following is my struts.xml


<struts>
<package name="tutorial" extends="struts-default">
<action name="HelloWorld" class="tutorial.HelloWorld">
<result>/HelloWorld.jsp</result>
</action>
<!-- Add your actions here -->
</package>
</struts>


I enter following in browser's url

http://localhost:8080/contextName/tutorial/HelloWorld.action.

Above works fine.

Now I add namespace


<struts>
<package name="tutorial" namespace="testSpace" extends="struts-default">
<action name="HelloWorld" class="tutorial.HelloWorld">
<result>/HelloWorld.jsp</result>
</action>
<!-- Add your actions here -->
</package>
</struts>

To my understanding it the resulting url should become

http://localhost:8080/contextName/testSpace/HelloWorld.action


But when I enter above url in the browser it says


Dec 18, 2008 9:32:46 PM org.apache.struts2.dispatcher.Dispatcher serviceAction
SEVERE: Could not find action or result
There is no Action mapped for action name HelloWorld. - [unknown location]
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy
.java:186) at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(St
rutsActionProxyFactory.java:41) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:494)
at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)




Please help.
Sagar Kale
Ranch Hand

Joined: May 02, 2008
Posts: 188
resolved it

<struts>
<package name="tutorial" namespace="testSpace" extends="struts-default">
<action name="HelloWorld" class="tutorial.HelloWorld">
<result>/HelloWorld.jsp</result>
</action>
<!-- Add your actions here -->
</package>
</struts>


should be


<struts>
<package name="tutorial" namespace="/testSpace" extends="struts-default">
<action name="HelloWorld" class="tutorial.HelloWorld">
<result>/HelloWorld.jsp</result>
</action>
<!-- Add your actions here -->
</package>
</struts>

Namespace should start with /.

But I still not able to find out if namespace do not start with /, what would be resulting url?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts2 namespace url problem
 
Similar Threads
Struts 2 doesn't see the Action mapping
requested resource (/tutorial/HellwWorld.action) is not available error
Struts 2 Tutorial �Hello World� Please Help!
struts2 out of the box problem
Struts 2 error