title: Spring & Hibernate @Valid doing nothing
body: <p>I have annotated my fields in my model and am using the @Valid annotation on my post controller but it appears to be performing no validation (result.errors is empty)</p>
  
  <p>Any ideas what might be causing this?</p>
  
  <p>Java based configuration:</p>
  
  <pre><code>@FeatureConfiguration
  public class MvcFeatures {
  
      @Feature
      public MvcAnnotationDriven annotationDriven() {
          return new MvcAnnotationDriven();
      }
  
      @Feature
      public MvcResources css() {
          return new MvcResources("/css/**", "/css/");
      }
  
      @Feature
      public MvcResources js() {
          return new MvcResources("/js/**", "/js/");
      }
  
      @Feature
      public MvcViewControllers viewController() {
          return new MvcViewControllers("/", "home");
      }
  
      @Feature
      public ComponentScanSpec componentScan() {
          return new ComponentScanSpec("com.webapp")
                  .excludeFilters(new AnnotationTypeFilter(Configuration.class),
                          new AnnotationTypeFilter(FeatureConfiguration.class));
      }
  
  }
  </code></pre>
  
  <p><br/><br/>
  Controller:</p>
  
  <pre><code>@Controller
  public class UserController extends AppController
  {
      static Logger logger = LoggerFactory.getLogger(UserController.class);
  
      @Autowired
      private IUserService userService;
  
      @RequestMapping(value = "/registration", method = RequestMethod.GET)
      public ModelAndView get()
      {
  
          ModelAndView modelAndView = new ModelAndView(Consts.MODEL_RESISTER_PAGE);
          modelAndView.addObject("user", new User());
  
          return modelAndView;
      }
  
      @RequestMapping(value = "/registration", method = RequestMethod.POST)
      public ModelAndView post(@Valid User user, BindingResult result)
      {
  
          if (result.hasErrors())
          {
              ModelAndView modelAndView = new ModelAndView(
                      Consts.MODEL_RESISTER_PAGE);
              modelAndView.addObject("user", result.getModel());
              return modelAndView;
          }
          else
          {
              // SAVE HERE
              ModelAndView modelAndView = new ModelAndView(
                      Consts.MODEL_RESISTER_PAGE);
              return modelAndView;
          }
      }
  }
  </code></pre>
  
  <p><br/><br/>
  Model:</p>
  
  <pre><code>@Entity
  public class User implements Serializable
  {
      /**
       * 
       */
      private static final long serialVersionUID = -5232533507244034448L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
  
      @NotEmpty
      @Size(min=2, max=15)
      private String firstname;
  
      @NotEmpty
      @Size(min=2, max=15)
      private String surname;
  
      @NotEmpty
      @Email
      private String email;
  
      @NotEmpty
      @Size(min=6, max=10)
      private String password;
  
      public Long getId()
      {
          return id;
      }
  
      public void setId(Long id)
      {
          this.id = id;
      }
  
      public String getFirstname()
      {
          return firstname;
      }
  
      public void setFirstname(String firstname)
      {
          this.firstname = firstname;
      }
  
      public String getSurname()
      {
          return surname;
      }
  
      public void setSurname(String surname)
      {
          this.surname = surname;
      }
  
      public String getEmail()
      {
          return email;
      }
  
      public void setEmail(String email)
      {
          this.email = email;
      }
  
      public String getPassword()
      {
          return password;
      }
  
      public void setPassword(String password)
      {
          this.password = password;
      }
  }
  </code></pre>
  
  <p><br/><br/>
  add.html (Using thymeleaf view resolver)</p>
  
  <pre><code>&lt;form id="registrationForm" action="#"
          th:action="@{/registration}" th:object="${user}" method="post"
          class="clearfix"&gt;
  
           &lt;legend&gt;Registration&lt;/legend&gt;
  
          &lt;div class="input"&gt;
            &lt;input type="text" th:field="*{firstname}"
              placeholder="Firstname" th:class="${#fields.hasErrors('firstname')}? 'fieldError'"
               /&gt;
          &lt;/div&gt;
  
          &lt;div class="input"&gt;
            &lt;input type="text" th:field="*{surname}" placeholder="Surname" /&gt;
          &lt;/div&gt;
  
          &lt;div class="input"&gt;
            &lt;input type="text" th:field="*{email}" placeholder="Email" /&gt;
          &lt;/div&gt;
  
          &lt;div class="input"&gt;
            &lt;input type="password" th:field="*{password}"
              placeholder="Password" /&gt;
          &lt;/div&gt;
  
          &lt;div class="clearfix"&gt;
            &lt;input type="submit" class="btn btn-success btn-large" value="Register" /&gt;
          &lt;/div&gt;
  
        &lt;/form&gt;
  </code></pre>
  
  <p><br/><br/>
  Pom:</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;ConsumerApplicaton&lt;/groupId&gt;
      &lt;artifactId&gt;ConsumerApplicaton&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  
      &lt;repositories&gt;
          &lt;repository&gt;
              &lt;snapshots&gt;
                  &lt;enabled&gt;false&lt;/enabled&gt;
              &lt;/snapshots&gt;
              &lt;id&gt;springsource-milestone&lt;/id&gt;
              &lt;name&gt;Spring Framework Milestone Repository&lt;/name&gt;
              &lt;url&gt;http://maven.springframework.org/milestone&lt;/url&gt;
          &lt;/repository&gt;
      &lt;/repositories&gt;
  
      &lt;dependencies&gt;
          &lt;!-- spring --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
              &lt;version&gt;${spring.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
              &lt;version&gt;${spring.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
              &lt;version&gt;${spring.version}&lt;/version&gt;
              &lt;exclusions&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;commons-logging&lt;/groupId&gt;
                      &lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
              &lt;/exclusions&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-oxm&lt;/artifactId&gt;
              &lt;version&gt;${spring.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- thymeleaf --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.thymeleaf&lt;/groupId&gt;
              &lt;artifactId&gt;thymeleaf&lt;/artifactId&gt;
              &lt;version&gt;${thymeleaf.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.thymeleaf&lt;/groupId&gt;
              &lt;artifactId&gt;thymeleaf-spring3&lt;/artifactId&gt;
              &lt;version&gt;${thymeleaf.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- persistence --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
              &lt;version&gt;3.1.0.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
              &lt;version&gt;3.6.9.Final&lt;/version&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
              &lt;version&gt;4.2.0.Final&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- json, xml, atom --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-mapper-asl&lt;/artifactId&gt;
              &lt;version&gt;${jackson-mapper-asl.version}&lt;/version&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.xml.bind&lt;/groupId&gt;
              &lt;artifactId&gt;jaxb-api&lt;/artifactId&gt;
              &lt;version&gt;${jaxb-api.version}&lt;/version&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;!-- DB --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;5.1.18&lt;/version&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;!-- logging --&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
              &lt;version&gt;${org.slf4j.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
              &lt;artifactId&gt;logback-classic&lt;/artifactId&gt;
              &lt;version&gt;1.0.1&lt;/version&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;jcl-over-slf4j&lt;/artifactId&gt;
              &lt;version&gt;${org.slf4j.version}&lt;/version&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;!-- Various --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;cglib&lt;/groupId&gt;
              &lt;artifactId&gt;cglib-nodep&lt;/artifactId&gt;
              &lt;version&gt;${cglib.version}&lt;/version&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;finalName&gt;ConsumerApplicaton&lt;/finalName&gt;
  
          &lt;plugins&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.2&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.6&lt;/source&gt;
                      &lt;target&gt;1.6&lt;/target&gt;
                      &lt;encoding&gt;UTF-8&lt;/encoding&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
      &lt;properties&gt;
          &lt;!-- VERSIONS --&gt;
          &lt;!-- &lt;spring.version&gt;3.1.0.RELEASE&lt;/spring.version&gt; --&gt;
          &lt;spring.version&gt;3.1.0.M1&lt;/spring.version&gt;
          &lt;cglib.version&gt;2.2.2&lt;/cglib.version&gt;
  
          &lt;thymeleaf.version&gt;2.0.11&lt;/thymeleaf.version&gt;
  
          &lt;jackson-mapper-asl.version&gt;1.9.5&lt;/jackson-mapper-asl.version&gt;
          &lt;jaxb-api.version&gt;2.2.6&lt;/jaxb-api.version&gt;
  
          &lt;!-- VERSIONS - persistence --&gt;
          &lt;mysql-connector-java.version&gt;5.1.18&lt;/mysql-connector-java.version&gt; &lt;!-- latest version on: 02.10.2011 - http://dev.mysql.com/downloads/connector/j/ --&gt;
          &lt;hibernate.version&gt;4.1.0.Final&lt;/hibernate.version&gt;
  
          &lt;!-- VERSIONS - logging --&gt;
          &lt;org.slf4j.version&gt;1.6.4&lt;/org.slf4j.version&gt;
      &lt;/properties&gt;
  
  &lt;/project&gt;
  </code></pre>