Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-4533

404 error with @Action("/") when upgrading Struts2 REST 2.1.8 to 2.3.24



    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.7, 2.3.8, 2.3.12, 2.3.14,,,, 2.3.15,,,, 2.3.16,,,, 2.3.20, 2.3.24
    • Fix Version/s: 2.3.28
    • Component/s: Plugin - REST
    • Environment:

      *ix System, Tomcat 6.0.44, Java 1.6


      I have a web app made using Struts 2 version 2.1.8, and its Convention and REST plugins. I needed to update it to the latest version (2.3.24) but one feature I used to have stopped working. I tracked the versions after 2.1.8, and found out that it was after version 2.3.7 that the problem started to happen. I have created a simple app called “upgradetest" to isolate the problem. Here is the error scenario:

      I have an Action called HomeController, in which I have a method index() that is marked with the @Action(“/“) annotation, so that the root url of the app maps to this method, like below:

      package upgradetest.web.struts;
      import org.apache.struts2.convention.annotation.Action;
      import org.apache.struts2.rest.RestActionSupport;
      import upgradetest.model.Messages;
      public class HomeController extends RestActionSupport {
          private Messages messages;
          public HomeController() {
          public String index() {
              messages = new Messages();
              return show();
          public String show() {
              return "show";
          public Messages getMessages() {
              return messages;

      Here is my struts.xml file:

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE struts PUBLIC
              "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
              <constant name="struts.devMode" value="true" />
              <package name="upgradetest" extends="struts-default">
              <constant name="struts.objectFactory" value="spring" />
              <constant name="struts.custom.i18n.resources" value="global-resources" />
              <constant name="struts.mapper.class" value="rest" />
              <constant name="struts.convention.action.suffix" value="Controller"/>
              <constant name="struts.convention.action.mapAllMatches" value="true"/>
              <constant name="struts.convention.default.parent.package" value="upgradetest"/>

      Normally, by visiting the root url of my app (“/“) in Struts2 2.1.8, the index() method was called, and it then took the user to the desired result. After the upgrade to 2.3.7, the web app is returning a 404 error. I have investigated the source code and found out that the RestActionMapper of Struts Rest Plugin is returning null in the getMapping method (in the last line of code), something it did not in version 2.1.8. I believe this change was done for some reason so I was wondering:

      Is there a way to map the root url (“/“) to a specific action of mine without having to do a redirect or something like that (because of a SEO requirement I have)? Also, am I doing it the wrong way?


          Issue Links



              • Assignee:
                julioaragao Julio Aragao
              • Votes:
                0 Vote for this issue
                4 Start watching this issue


                • Created: