This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I created this directory: $CATALINA_BASE/webapps/HelloWorld with this structure:
../WEB-INF/classes/tutorial/HelloWorld.java and HelloWorld.class
../WEB-INF/lib/ -> filled with all the libs needed.
(HelloWorld.jsp, struts.xml and web.xml are just copy/paste from the same files I found in the tutorial above)
I fired up Tomcat and I deployed the application using the tomcat manager and I get this message: "OK - Started application at context path /HelloWorld" but browsing localhost:8080/HelloWorld leads to this error: HTTP Status 404 - There is no Action mapped for namespace / and action name .
As I said I looked inside the tomcat logs and on many many forums still I dont have a clue. :O
It sounds like you don't have a welcome page identified for your web application.
You've created a web application named "HelloWorld" (based on the name of the directory you created under "webapps".
When you browse to localhost:8080/HelloWorld, this is accessing the root of your web application, not the JSP page you have in the root of your web application. What happens when you try browsing to localhost:8080/HelloWorld/HelloWorld.jsp?
Otherwise, perhaps you could show the contents of your web.xml file (please use code tags for that).
You're totally right, if I try to access /HelloWorld/HelloWorld.jsp I get rid of that error. Adding a <welcome-file-list> into web.xml should solve the problem (forgot this step after an entire day of fails using netbeans)
Anyway another problem has arisen: the browser returns a blank page (the title is setted properly, afterall).
If the context is HelloWorld, and the action name is HelloWorld, then the appropriate URL would be /HelloWorld/HelloWorld.
Joined: Feb 22, 2010
Lamest thread award.
Thank you Dave, it works. I would like to say that I got lot of problems with NetBeans+Struts2 in the first place and after a day of fails I tried to build the project manually and this thread actually show how I was tired
Anyway, thanks to your answers, looks like I've solved the problem even with NetBeans.. in fact the first problem was I placed struts.xml in the wrong dir (it should be under the default package) and the second arise when you run the project, NetBeans automatically opens a wrong url (localhost:8080/HelloWorld withouth the action part).
I am also facing the same problem. I have tried different alternatives but failed to resolve
I am getting the welcome page and initPersonAction is working properly... but, when I try to invoke other actions it is giving me the problem:
2010-10-25 18:17:09,814 ERROR [org.apache.struts2.dispatcher.Dispatcher] - <Could not find action or result>
There is no Action mapped for namespace / and action name addPersonAction!add. - [unknown location]
I am trying to access one Action class with different action names and method names.