title: Spring Web Flow validator not found
body: <p>I am trying to do form validation in Spring Web Flow. For this I am using a validator class, which is named after the model. Just like it is stated in the documentation.
  The validator gets instantiated as a bean but is never called during validation. Any pointers on that issue?</p>
  
  <p><strong>flow config</strong></p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;flow xmlns="http://www.springframework.org/schema/webflow"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow-2.4.xsd"&gt;
  
      &lt;view-state id="createTotpKeyView" view="/templates/totp/create/create" model="key"&gt;
          &lt;on-entry&gt;
              &lt;evaluate expression="createTotpKeyAction"/&gt;
          &lt;/on-entry&gt;
          &lt;transition on="submit" to="successfullyCreated" bind="true" validate="true"/&gt;
      &lt;/view-state&gt;
  
      &lt;end-state id="successfullyCreated" view="/templates/totp/create/success"/&gt;
  &lt;/flow&gt;
  </code></pre>
  
  <p>This is the action that is called in the view-state.</p>
  
  <p><strong>createTotpKeyAction</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>@Component
  public class CreateTotpKeyAction implements Action
  {
      String uid = "random";
  
      @Override
      public Event execute(RequestContext context) throws Exception
      {
          try
          {
              // Create a TOTP key and put it in the view scope
              TOTPKey totpKey = client.createTotpKeyForUid(uid, null);
              context.getViewScope().put("key", totpKey);
  
              return new Event(this, "success");
          }
          catch (Exception e)
          {
              log.error("Error while creating TOTP key for user: " + uid + ".\n" + e.getMessage());
              // Put response message in flash scope to show it once
              context.getFlashScope().put("fetchingError", true);
              return new Event(this, "error");
          }
      }
  }
  </code></pre>
  
  <p>This is the validator I am trying to use. <strong>EDIT</strong> renamed to match documentation.</p>
  
  <p><strong>KeyValidator</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>@Component
  public class KeyValidator
      {
          [...]
  
      public void validateCreateTotpKeyView(TOTPKey key, ValidationContext context)
      {
          System.out.println("VALIDATE VIEW STATE");
      }
  
      public void validate(TOTPKey key, ValidationContext context)
      {
          System.out.println("DEFAULT VALIDATE");
      }
  }
  </code></pre>
  
  <p>I also tried different naming schemes such as <code>TOTPKeyValidator</code> or <code>TotpKeyValidator</code>. None of them worked.</p>
  
  <p>The only thing that is working, is creating a validation method in the <code>TOTPKey</code> class, but I don't want to use that approach.</p>
  
  <p>In addition this is the log file produced during the attempted validation</p>
  
  <p><strong>Log</strong></p>
  
  <pre><code>Mapping request with URI '/totp/create' to flow with id 'totp/create'
  Resuming flow execution with key 'e5s1
  Locking conversation 5
  Getting flow execution with key 'e5s1'
  Getting FlowDefinition with id 'totp/create'
  Resuming in org.springframework.webflow.mvc.servlet.MvcExternalContext@2b551393
  Restoring [FlowVariable@3b66a2de name = 'key', valueFactory = [BeanFactoryVariableValueFactory@2fbc89 type = TOTPKey]]
  Processing user event 'submit'
  Resolved model twofa.core.domain.TOTPKey@505439d0
  Binding to model
  Adding default mapping for parameter 'execution'
  Adding default mapping for parameter 'totpKeyId'
  Adding default mapping for parameter 'token'
  Adding empty value mapping for parameter 'eventId_submit'
  Validating model
  Event 'submit' returned from view [ServletMvcView@19f8532f view = org.springframework.web.servlet.view.velocity.VelocityLayoutView: name '/templates/totp/create/create'; URL [/templates/totp/create/create.vm]]
  Executing [Transition@2feb5361 on = submit, to = successfullyCreated]
  Exiting state 'createTotpKeyView'
  Entering state 'successfullyCreated' of flow 'totp/create'
  Executing org.springframework.webflow.action.ViewFactoryActionAdapter@423fa131
  Rendering MVC [org.springframework.web.servlet.view.velocity.VelocityLayoutView: name '/templates/totp/create/success'; URL [/templates/totp/create/success.vm]] with model map [{currentUser=null, flashScope=map[[empty]], flowRequestContext=[RequestControlContextImpl@70144045 externalContext = org.springframework.webflow.mvc.servlet.MvcExternalContext@2b551393, currentEvent = submit, requestScope = map[[empty]], attributes = map[[empty]], messageContext = [DefaultMessageContext@149807b4 sourceMessages = map[[null] -&gt; list[[empty]]]], flowExecution = [FlowExecutionImpl@1c4b2c3e flow = 'totp/create', flowSessions = list[[FlowSessionImpl@6eea5d26 flow = 'totp/create', state = 'successfullyCreated', scope = map['key' -&gt; twofa.core.domain.TOTPKey@73f32d0a]]]]], flowExecutionKey=e5s1, flowExecutionUrl=/totp/create?execution=e5s1, key=twofa.core.domain.TOTPKey@73f32d0a}]
  Finished executing org.springframework.webflow.action.ViewFactoryActionAdapter@423fa131; result = success
  Completed transition execution.  As a result, the flow execution has ended
  Removing flow execution '[Ended execution of 'totp/create']' from repository
  Ending conversation 5
  Unlocking conversation 5
  </code></pre>
  
  <p>It says <code>Validating Model</code> but nothing happens...</p>