File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 2 doesn't see the Action mapping

 
Brian Manahan
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I've set up the official Struts 2 hello world example (found at http://struts.apache.org/2.x/docs/hello-world.html). The action is defined like this in struts.xml:



The project is deployed on the server as tutorial, and when I attempt to access "localhost:8080/tutorial/HelloWorld.action" I get this message:

There is no Action mapped for namespace / and action name HelloWorld.

Has anyone run into this problem and found a way to fix it? I altered the package and action a number of times but nothing worked. I verified that all of the files are on Tomcat and the application starts without a problem.
 
Brian Manahan
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, I did try adding namespace="/" to the package as is done in the mailreader example, but that did not work.
 
Brian Manahan
Greenhorn
Posts: 7
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solved problem. Unlike Struts 1 where struts-config.xml went in WEB-INF, Struts 2 looks for struts.xml in the base class directory.
 
raman nanda
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nice i like people that solve their own problems. This is the problem that every beginner of the struts developer faces you can just see that by the amount of search results that show. They generally try to do other things and only thing needed is to place the struts.xml under the classes directory
 
Ankit Garg
Sheriff
Posts: 9497
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
raman please Dont Wake The Zombies, that thread is 2 years old.
 
Narsimha Manekar
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had the same problem. I have been searching all over the internet and Brian's reply is the ONLY one that is a precise solution for this problem.

>>Solved problem. Unlike Struts 1 where struts-config.xml went in WEB-INF, Struts 2 looks for struts.xml in the base class directory.

I went back and read http://struts.apache.org/2.1.8/docs/simple-setup.html web page. I realised which part I overlooked. To clarify
read
/tutorial/WEB-INF/classes/
as
/tutorial/WEB-INF/classes/struts.xml


Thanks Brian.

-Rao
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic