You might have possibly configured all requests to go to struts.xml from your web.xml.

However when doing a http://localhost/ , you hit the error:

There is no Action mapped for namespace / and action name

This is because Struts 2 is unable to find the action name, which is none, under the namespace / .

If you are using Struts2 over JBoss AS, you need to do three things.

First

Descend to your server deploy root in search of the file “ROOT.WAR”, ROOT.WAR is what you see when you hit http://localhost:8080/ or http://localhost/ or http://myDomainName depending on how you have configured your listening port.

Search and delete the file “ROOT.WAR”.

You may find ROOT.WAR in three or four folders under /server, the server profile that you are usually using should be “default”, so descend into default, delete the file ROOT.WAR.

ROOT.WAR is usually found in

/opt/jbossas/server/default/deploy

In Linux, you may issue the following command to find ROOT.WAR

$ find / -name “ROOT.WAR” -print

Second

Preferred method (Because it is not always the case you are deploying your .WAR as a standalone, it may be part of a .EAR enterprise archive)

In web application that you are trying to fix as the root application, under/WEB-INF folder, create the file “jboss-web.xml” if you do not already have one.

Enter this into jboss-web.xml:

JBoss Web Configuration

jboss-web.xml

The file should be placed under /WEB-INF/jboss-web.xml . It would be of interest to anyone that contents placed under /WEB-INF is protected from public direct access.

Non preferred method (Quick and easy)

Rename the web application that you are trying to fix as the root application to “ROOT.WAR” from whatever name it was given or using.

Third

In struts.xml, insert the code snippet. you should change out your redirect action and namespace accordingly. For this, i have requested redirection to the initLogin action of the secure namespace. Theoretically, the same action may be accessed by http://localhost/mywebapp/secure/initLogin.

Struts2 Configuration Descriptor

struts.xml

Lastly

Redeploy to take effect. If you have turned off hot deploy, you may need to restart the server to take effect!

Share