title: Can't call action using annotation in Struts 2
body: <p>Here is my action class:</p>
  
  <p><strong><code>FirstAction.java</code>:</strong></p>
  
  <pre class="lang-java prettyprint-override"><code> @Namespace(value = "/User")
   public class FirstAction extends ActionSupport {
  
  /**
   * 
   */
  private static final long serialVersionUID = 1L;
  
  @Action(value = "run4", results = { @Result(name = "task1", location = "task1.jsp") })
  private String task1() {
      return "task1";
  }
  
  @Action(value = "run5", results = { @Result(name = "task2", location = "task2.jsp") })
  private String task2() {
      return "task2";
  }
  
  @Action(value = "run6", results = { @Result(name = "task3", location = "task3.jsp") })
  private String task3() {
      return "task3";
  }
  }
  </code></pre>
  
  <p><strong><code>SecondAction.java</code>:</strong></p>
  
  <pre class="lang-java prettyprint-override"><code> @Namespace(value = "/Admin")
  public class SecondAction extends ActionSupport {
  
  /**
   * 
   */
  private static final long serialVersionUID = 1L;
  
  @Action(value = "run1", results = { @Result(name = "task1", location = "task1.jsp") })
  private String task1() {
      return "task1";
  }
  
  @Action(value = "run2", results = { @Result(name = "task2", location = "task2.jsp") })
  private String task2() {
      return "task2";
  }
  
  @Action(value = "run3", results = { @Result(name = "task3", location = "task3.jsp") })
  private String task3() {
      return "task3";
  }
  }
  </code></pre>
  
  <p><strong><code>struts.xm</code>l:</strong></p>
  
  <pre class="lang-xml prettyprint-override"><code> &lt;struts&gt;
      &lt;constant name="struts.action.extension" value="html" /&gt;
      &lt;package name="default" extends="struts-default"&gt;&lt;/package&gt;
  &lt;/struts&gt;
  </code></pre>
  
  <p><strong><code>web.xml</code>:</strong></p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;welcome-file-list&gt;
     &lt;welcome-file&gt;redirect.jsp&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  &lt;filter&gt;
  &lt;filter-name&gt;struts2&lt;/filter-name&gt;
  &lt;filter-class&gt;
      org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
  &lt;/filter-class&gt;
  &lt;init-param&gt;
      &lt;param-name&gt;actionPackages&lt;/param-name&gt;
      &lt;param-value&gt;com.sem4.actions&lt;/param-value&gt;
  &lt;/init-param&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;struts2&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  &lt;!-- Session Config --&gt;
  &lt;session-config&gt;
      &lt;session-timeout&gt;30&lt;/session-timeout&gt;
  &lt;/session-config&gt;
  </code></pre>
  
  <p>This is <code>redirect.jsp</code>:</p>
  
  <pre class="lang-jsp prettyprint-override"><code> &lt;div&gt;
        &lt;a href='&lt;s:url action="run1" namespace="Admin"&gt;&lt;/s:url&gt;'&gt;Action run1, namespace Admin&lt;/a&gt;
          &lt;br&gt; 
          &lt;a href='&lt;s:url action="run2" namespace="Admin"&gt;&lt;/s:url&gt;'&gt;Action run2, namespace Admin&lt;/a&gt; 
          &lt;br&gt; 
          &lt;a href='&lt;s:url action="run3" namespace="Admin"&gt;&lt;/s:url&gt;'&gt;Action run3, namespace Admin&lt;/a&gt;
   &lt;/div&gt;
   &lt;div&gt;
        &lt;a href='&lt;s:url action="run4" namespace="User"&gt;&lt;/s:url&gt;'&gt;Action run1, namespace User&lt;/a&gt; 
          &lt;br&gt; 
          &lt;a href='&lt;s:url action="run5" namespace="User"&gt;&lt;/s:url&gt;'&gt;Action run2, namespace User&lt;/a&gt;
          &lt;br&gt; 
           &lt;a href='&lt;s:url action="run6" namespace="User"&gt;&lt;/s:url&gt;'&gt;Action run3, namespace User&lt;/a&gt;
   &lt;/div&gt;
  </code></pre>
  
  <p>And my library:</p>
  
  <pre><code>  antlr-2.7.6.jar
    commons-collections-3.1.jar
    commons-fileupload-1.2.1.jar
    commons-io-1.3.2.jar
    commons-lang-2.3.jar
    commons-logging-1.1.jar
    dom4j-1.6.1.jar
    ejb3-persistence.jar
    freemarker-2.3.13.jar
    hibernate-annotations.jar
    hibernate-commons-annotations.jar
    hibernate-validator.jar
    hibernate3.jar
    hsqldb.jar
    javassist-3.9.0.GA.jar
    jta-1.1.jar
    junit-3.8.1.jar
    log4j-1.2.15.jar
    mysql-connector-java-5.0.7-bin.jar
    ognl-2.6.11.jar
    slf4j-api-1.5.8.jar
    slf4j-log4j12-1.5.8.jar
    struts2-convention-plugin-2.1.6.jar
    struts2-core-2.1.6.jar
    struts2-fullhibernatecore-plugin-1.4-GA.jar
    xwork-2.1.2.jar
  </code></pre>
  
  <p>When I click a link in <code>redirect.jsp</code> to call an action, ex: call action <code>run4</code> in namespace <code>"User"</code>, it's throwing </p>
  
  <pre><code>  HTTP Status 404 - There is no Action mapped for namespace /User and action name run4
  </code></pre>
  
  <p>I'm trying to find what makes this wrong, but it looks like my code is fine. </p>