title: Method Not Found in JSF Bean
body: <p>I have completed an application using JSF 1.x, which is up and running.</p>
  
  <p>The application has 2 parts, one being invoke a action event and display the same page, and the second being invoke a method and navigate to next page. Typical  Hello world Example.</p>
  
  <p>But the Second part of the application is not working as it is not finding the method in the bean class.</p>
  
  <p>The 'Goodbye' button in <code>hello.jsp</code>is not working.</p>
  
  <p>I invoked the Url <code>http://localhost:8090/balaji/faces/JSP/hello.jsp</code> which is executing correctly displaying me the hello.jsp page.</p>
  
  <p>But the Goodbye Button in hello.jsp page is not working, which when clicked will not change the URL. But i got the error on stack trace as shown below. The Method is existing and it is public, EL expression is correct, navigation rule is set, JSP page exist, but the method is not responding.</p>
  
  <p>My Stack Trace show the following Error: </p>
  
  <p><strong>Stacktrace:</strong> </p>
  
  <pre><code>13 Dec, 2012 7:17:19 PM javax.faces.event.MethodExpressionActionListener processAction
  SEVERE: Received 'org.apache.jasper.el.JspMethodNotFoundException' when invoking action listener '#{helloBean.goodbye}' for component 'goodbyeCommand'
  13 Dec, 2012 7:17:19 PM javax.faces.event.MethodExpressionActionListener processAction
  SEVERE: org.apache.jasper.el.JspMethodNotFoundException: /JSP/hello.jsp(40,2) '#{helloBean.goodbye}' Method not found: com.achutha.bean.HelloBean@46a5c4.goodbye(javax.faces.event.ActionEvent)
      at org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:73)
      at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:99)
      at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
      at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:771)
      at javax.faces.component.UICommand.broadcast(UICommand.java:372)
      at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
      at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)
      at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:931)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
      at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1822)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:662)
  </code></pre>
  
  <p>My Application Structure is as follows :</p>
  
  <p><strong>Package Structure :</strong></p>
  
  <p><img src="https://i.stack.imgur.com/TnrLX.jpg" alt="poc"></p>
  
  <p><strong>Maven Dependencies :</strong> </p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;com.achutha.labs&lt;/groupId&gt;
      &lt;artifactId&gt;02JsfExample&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;name&gt;02JsfExample&lt;/name&gt;
  
      &lt;dependencies&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;javax.faces&lt;/groupId&gt;
              &lt;artifactId&gt;jsf-api&lt;/artifactId&gt;
              &lt;version&gt;1.2_14&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.faces&lt;/groupId&gt;
              &lt;artifactId&gt;jsf-impl&lt;/artifactId&gt;
              &lt;version&gt;1.2_14&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;jstl&lt;/artifactId&gt;
              &lt;version&gt;1.2&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
              &lt;version&gt;2.5&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt;
              &lt;artifactId&gt;jsp-api&lt;/artifactId&gt;
              &lt;version&gt;2.1&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- EL --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.web&lt;/groupId&gt;
              &lt;artifactId&gt;el-impl&lt;/artifactId&gt;
              &lt;version&gt;2.2&lt;/version&gt;
          &lt;/dependency&gt;
  
  
      &lt;/dependencies&gt;
  
  
      &lt;build&gt;
          &lt;finalName&gt;JavaServerFaces&lt;/finalName&gt;
  
          &lt;plugins&gt;
  
              &lt;plugin&gt;
                  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                  &lt;artifactId&gt;tomcat-maven-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;url&gt;http://localhost:8090/manager/text&lt;/url&gt;
                      &lt;server&gt;TomcatServer&lt;/server&gt;
                      &lt;path&gt;/balaji&lt;/path&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
  
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.3.1&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.6&lt;/source&gt;
                      &lt;target&gt;1.6&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p><strong>Faces Configuration :</strong></p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!DOCTYPE faces-config PUBLIC
       "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
       "http://java.sun.com/dtd/web-facesconfig_1_0.dtd"&gt;
  
  &lt;faces-config&gt;
      &lt;managed-bean&gt;
          &lt;description&gt; The one and only HelloBean.&lt;/description&gt;
          &lt;managed-bean-name&gt;helloBean&lt;/managed-bean-name&gt;
          &lt;managed-bean-class&gt;com.achutha.bean.HelloBean&lt;/managed-bean-class&gt;
          &lt;managed-bean-scope&gt;session&lt;/managed-bean-scope&gt;
      &lt;/managed-bean&gt;
  
  
  
      &lt;navigation-rule&gt;
          &lt;description&gt;Navigation From the Hello Page.&lt;/description&gt;
          &lt;from-view-id&gt;/JSP/hello.jsp&lt;/from-view-id&gt;
          &lt;navigation-case&gt;
              &lt;from-outcome&gt;success&lt;/from-outcome&gt;
              &lt;to-view-id&gt;/JSP/goodbye.jsp&lt;/to-view-id&gt;
          &lt;/navigation-case&gt;
      &lt;/navigation-rule&gt;
  
  &lt;/faces-config&gt;
  </code></pre>
  
  <p><strong>Deployment Descriptor (web.xml) :</strong></p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;!DOCTYPE web-app
          PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
          "http://java.sun.com/dtd/web-app_2_3.dtd"&gt;
  
     &lt;web-app version="2.5"
        xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
        http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
  
          &lt;display-name&gt;Hello, World!&lt;/display-name&gt;
          &lt;description&gt;Welcome to JavaServer Faces&lt;/description&gt;
  
          &lt;servlet&gt;
              &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
              &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;
              &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
          &lt;/servlet&gt;
  
          &lt;servlet-mapping&gt;
              &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
              &lt;url-pattern&gt;/faces/*&lt;/url-pattern&gt;
          &lt;/servlet-mapping&gt;
  
          &lt;welcome-file-list&gt;
              &lt;welcome-file&gt;faces/JSP/hello.jsp&lt;/welcome-file&gt;
          &lt;/welcome-file-list&gt;
  
  
      &lt;/web-app&gt;
  </code></pre>
  
  <p><strong>hello.jsp</strong></p>
  
  <pre><code>&lt;%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%&gt;
  &lt;%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%&gt;
  
  &lt;f:view&gt;
      &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;JSF In Action - Hello, world!&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h:form id="welcomeForm"&gt;
          &lt;h:outputText id="welcomeOutput" value="Welcome to JavaServer Faces !"
              style="font-family: Arial, sans-serif; font-size: 23; color: green;" /&gt;
  
          &lt;p&gt;
              &lt;h:message id="errors" for="helloInput" style="color: red" /&gt;
          &lt;/p&gt;
  
          &lt;p&gt;
              &lt;h:outputLabel for="helloInput"&gt;
                  &lt;h:outputText id="helloInputLabel"
                      value="Enter Number of controls to display: "&gt;
  
                  &lt;/h:outputText&gt;
  
                  &lt;h:inputText id="helloInput" value="#{helloBean.numControls}"
                      required="true"&gt;
                      &lt;f:validateLongRange minimum="1" maximum="500" /&gt;
                  &lt;/h:inputText&gt;
              &lt;/h:outputLabel&gt;
          &lt;/p&gt;
  
          &lt;p&gt;
              &lt;h:panelGrid id="controlPanel" binding="#{helloBean.controlPanel}"
                  columns="20" border="1" cellspacing="0" /&gt;
          &lt;/p&gt;
  
          &lt;h:commandButton id="redisplayCommand" type="submit" value="Redisplay"
              actionListener="#{helloBean.addControls}" /&gt;
  
          &lt;h:commandButton id="goodbyeCommand" type="submit" value="Goodbye"
              actionListener="#{helloBean.goodbye}" immediate="true"/&gt;
  
      &lt;/h:form&gt;
  
  &lt;/body&gt;
  
      &lt;/html&gt;
  
  &lt;/f:view&gt;
  </code></pre>
  
  <p><strong>goodbye.jsp :</strong></p>
  
  <pre><code>&lt;%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%&gt;
  &lt;%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%&gt;
  &lt;f:view&gt;
      &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Jsf in Action - Hello World!&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h:form id="goodbyeForm"&gt;
          &lt;p&gt;
              &lt;h:outputText id="welcomeOutput" value="Good Bye"
                  style="font-family: Arial, sans-serif; font-size: 24; font-style: bold; color: green;" /&gt;
  
          &lt;/p&gt;
          &lt;p&gt;
              &lt;h:outputText id="helloBeanOutputLabel"
                  value="Number of controls displayed: " /&gt;
              &lt;h:outputText id="helloBeanOutputLabel"
                  value="#{helloBean.numControls}" /&gt;
          &lt;/p&gt;
      &lt;/h:form&gt;
  
  &lt;/body&gt;
      &lt;/html&gt;
  &lt;/f:view&gt;
  </code></pre>
  
  <p><strong>Bean class :</strong></p>
  
  <pre><code>package com.achutha.bean;
  
  import java.util.List;
  
  import javax.faces.application.Application;
  import javax.faces.component.UIComponent;
  import javax.faces.component.html.HtmlOutputText;
  import javax.faces.component.html.HtmlPanelGrid;
  import javax.faces.context.FacesContext;
  import javax.faces.event.ActionEvent;
  
  public class HelloBean {
  
      private int numControls;
      private HtmlPanelGrid controlPanel;
  
      public int getNumControls() {
          return numControls;
      }
  
      public void setNumControls(int numControls) {
          this.numControls = numControls;
      }
  
      public HtmlPanelGrid getControlPanel() {
          return controlPanel;
      }
  
      public void setControlPanel(HtmlPanelGrid controlPanel) {
          this.controlPanel = controlPanel;
      }
  
      public void addControls(ActionEvent actionEvent) {
          Application application = FacesContext.getCurrentInstance()
                  .getApplication();
  
          List&lt;UIComponent&gt; children = controlPanel.getChildren();
  
          children.clear();
  
          for (int count = 0; count &lt; numControls; count++) {
              HtmlOutputText output = (HtmlOutputText) application
                      .createComponent(HtmlOutputText.COMPONENT_TYPE);
              output.setValue(" " + count + " ");
              output.setStyle("color: blue");
              children.add(output);
          }
      }
  
      public String goodbye() {
          return "success";
      }
  
  }
  </code></pre>
  
  <p><strong>Clean Deployment :</strong> The application is deploying itself fine on Tomcat 7. I checked the deployed package structure on &amp;tomcat_home%/webapps and all the JSP files are intact in proper place as expected.</p>
  
  <p>I am not able to figure out  the error, and what makes 'GoodBye' button trigger ?</p>