title: Spring MVC validation form with annotations
body: <p>I was trying to perform validation with <a href="https://spring.io/guides/gs/validating-form-input/" rel="nofollow">https://spring.io/guides/gs/validating-form-input/</a> and I added annotations like <code>@NotNull, @Size(min = 5, max = 40)</code>. When I send correct values everything is fine, but when I send wrong values firstly I have this error from Apache Tomcat/7.0.47: </p>
  
  <blockquote>
    <p>HTTP Status 500 - Handler processing failed; nested exception is java.lang.ExceptionInInitializerError </p>
    
    <p>type Exception report</p>
    
    <p>message Handler processing failed; nested exception is java.lang.ExceptionInInitializerError
    description The server encountered an internal error that prevented it from fulfilling this request.</p>
    
    <p>exception org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.ExceptionInInitializerError </p>
    
    <p>javax.el.ELException: Unable to find ExpressionFactory of type: org.apache.el.ExpressionFactoryImpl</p>
    
    <p>java.lang.ExceptionInInitializerError</p>
    
    <p>javax.el.ELException: Unable to find ExpressionFactory of type: org.apache.el.ExpressionFactoryImpl</p>
  </blockquote>
  
  <p>When I refresh the site and try sending wrong values again I get a different error:</p>
  
  <blockquote>
    <p>HTTP Status 500 - Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.messageinterpolation.InterpolationTerm</p>
    
    <p>type Exception report</p>
    
    <p>message Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.messageinterpolation.InterpolationTerm</p>
    
    <p>description The server encountered an internal error that prevented it from fulfilling this request.</p>
    
    <p>exception org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.messageinterpolation.InterpolationTerm</p>
    
    <p>java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.messageinterpolation.InterpolationTerm</p>
  </blockquote>
  
  <p><strong>This is the action in my controller:</strong></p>
  
  <pre><code>@RequestMapping(value = "testform", method=RequestMethod.GET)
  public String testForm(Foo foo){
      return "test/testform";
  }
  
  @RequestMapping(value="testform", method=RequestMethod.POST)
  public String checkPersonInfo(@Valid Foo foo, BindingResult bindingResult) {
      if (bindingResult.hasErrors()) {
          return "test/testform";
      }
      return "redirect:/admin/venue/testform";
  }
  </code></pre>
  
  <p><strong>And view:</strong></p>
  
  <pre><code>&lt;form action="#" th:action="@{/admin/venue/testform}" th:object="${foo}" method="post"&gt;
  &lt;table&gt;
      &lt;tr&gt;
          &lt;td&gt;Name:&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" th:field="*{name}" /&gt;&lt;/td&gt;
          &lt;!--&lt;td th:if="${#fields.hasErrors('name')}" th:errors="*{name}"&gt;Name Error&lt;/td&gt;--&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;button type="submit"&gt;Submit&lt;/button&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p></p>
  
  <p>Any ideas how to resolve this problem? Maybe Tomcat is missing some libs?</p>