title: Spring MVC, Hibernate 3 and @Valid Problem
body: <p>I have a Spring MVC with JDBC that uses @Valid annotations and it all works very nicely, including the validation.</p>
  
  <p>Now I have created a similar webapp that uses <strong>Hibernate</strong> (instead of JDBC) and it also works nicely so far.</p>
  
  <p>I decided to 'bolt in' validation before continuing with more domains etc.</p>
  
  <p>So I added <strong>@Valid</strong> to the save process in the Controller as so:</p>
  
  <pre><code>@RequestMapping(value = "/productgroup/save", method = RequestMethod.POST)
  public String updateProductGroup(**@Valid** ProductGroup productGroup, BindingResult bindingResult) 
  </code></pre>
  
  <p>That is the <strong>only</strong> change that I make and now it crashes with:</p>
  
  <pre>SEVERE: Servlet.service() for servlet appServlet threw exception
  java.lang.NoSuchMethodError: javax.persistence.Persistence.getPersistenceUtil()Ljavax/persistence/PersistenceUtil;
      at org.hibernate.validator.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:33)
      at org.hibernate.validator.engine.resolver.DefaultTraversableResolver.isReachable(DefaultTraversableResolver.java:112)
      at org.hibernate.validator.engine.resolver.SingleThreadCachedTraversableResolver.isReachable(SingleThreadCachedTraversableResolver.java:47)
      at org.hibernate.validator.engine.ValidatorImpl.isValidationRequired(ValidatorImpl.java:764)
      at org.hibernate.validator.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:331)
      at org.hibernate.validator.engine.ValidatorImpl.validateConstraintsForRedefinedDefaultGroup(ValidatorImpl.java:278)
      at org.hibernate.validator.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:260)
      at org.hibernate.validator.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:213)
      at org.hibernate.validator.engine.ValidatorImpl.validate(ValidatorImpl.java:119)
      at org.springframework.validation.beanvalidation.SpringValidatorAdapter.validate(SpringValidatorAdapter.java:86)</pre>
  
  <p>I am using:
          
              org.hibernate
              hibernate-validator
              4.0.2.GA
              jar
          
          
              javax.validation
              validation-api
              1.0.0.GA
          </p>
  
  <p>I have tried @NotEmpty on both the ProductGroup's productGroupName field and its Getter.</p>
  
  <p>Any ideas?</p>
  
  <p>I really never expected any problems here as I had no problems getting validation to work in my JDBC version...</p>