title: Spring Webflow + Spring MVC: Action Bean in Java Annotation
body: <p>I'm using Spring MVC + Spring Webflow 2. </p>
  
  <p>I would like to define a @Bean for an action-state, but i don't know how to do this in Java Annotation, as i get this error:</p>
  
  <blockquote>
    <p>Method call: Method execute() cannot be found on
    com.myapp.action.GaraAgenziaAction type</p>
  </blockquote>
  
  <p>here an example of what i want to do: <a href="https://stackoverflow.com/questions/15575717/spring-webflow-no-actions-were-executed">spring-webflow-no-actions-were-executed</a></p>
  
  <p>My Bean:</p>
  
  <pre><code>import org.springframework.webflow.execution.Action;
  import org.springframework.webflow.execution.Event;
  import org.springframework.webflow.execution.RequestContext;
  
  public class GaraAgenziaAction implements Action {
  
      @Override
      public Event execute(RequestContext rc) throws Exception {                
          return new Event(this, "success");
      }
  }
  </code></pre>
  
  <p>Flow XML:</p>
  
  <p>
            </p>
  
  <pre><code>&lt;transition on="fail" to="gara-agenzie"/&gt;
  
  &lt;transition on="success" to="gara-conferma"/&gt;
  </code></pre>
  
  <p></p>
  
  <p>My webAppConfig:</p>
  
  <pre><code>@Bean
  public Action GaraAgenziaAction()
  {
      GaraAgenziaAction garaAgenziaAction = new GaraAgenziaAction();
  
      return garaAgenziaAction;
  
  }
  </code></pre>
  
  <p>Thank you very much</p>
  
  <p><br><br>
  <strong>UPDATE resolved thanks to @Prasad suggestions:</strong></p>
  
  <p>My Bean (added @Component):</p>
  
  <pre><code>import org.springframework.stereotype.Component;
  import org.springframework.webflow.execution.Action;
  import org.springframework.webflow.execution.Event;
  import org.springframework.webflow.execution.RequestContext;
  
  @Component
  public class GaraAgenziaAction implements Action {
  
      @Override
      public Event execute(RequestContext rc) throws Exception {                
          return new Event(this, "success");
      }
  }
  </code></pre>
  
  <p>My webAppConfig (changed name of the bean with lowercase):</p>
  
  <pre><code>@Bean
  public Action garaAgenziaAction()
  {
      GaraAgenziaAction beanAction = new GaraAgenziaAction();
  
      return beanAction;
  
  }
  </code></pre>
  
  <p>Flow XMl configuration (changed bean name to lowercase and pass <strong>flowRequestContext</strong> as parameter):</p>
  
  <pre><code>&lt;action-state id="action-agenzie"&gt;
      &lt;evaluate expression="garaAgenziaAction.execute(flowRequestContext)"&gt;&lt;/evaluate&gt;        
  
      &lt;transition on="fail" to="gara-agenzie"/&gt;
  
      &lt;transition on="success" to="gara-conferma"/&gt;
  &lt;/action-state&gt;
  </code></pre>
  
  <p>Now it's working fine!</p>