34

I get an error when trying to set up Spring MVC validation.

javax.validation.ValidationException: Unable to find a default provider

I read in the documents that the default provider they use is the hibernate-validator. Do I need to include this library to get validation to work? Is it okay to include this library even though i'm not using hibernate for my project?

axtavt
  • 239,438
  • 41
  • 511
  • 482
Kyle
  • 21,377
  • 37
  • 113
  • 200

3 Answers3

44

If you are using Maven, you must add a dependency to the Hibernate Validator Annotation Processor.

<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-validator-annotation-processor</artifactId>
  <version>4.1.0.Final</version>
</dependency>

You can find it in the JBoss repository :

<repository>
  <id>JBoss Repository</id>
  <url>https://repository.jboss.org/nexus/content/repositories/releases</url>
  <name>JBoss Repository</name>
</repository>
Stéphane B.
  • 3,260
  • 2
  • 30
  • 35
  • 1
    Only use "hibernate-validator", not "hibernate-validator-annotation-processor", the latter adds more to the project than you need. – tkruse Jun 27 '16 at 11:54
27

Yes, you should include Hibernate Validator library in order to use it. It doesn't depend on Hibernate itself.

axtavt
  • 239,438
  • 41
  • 511
  • 482
1

Make sure you're using Hibernate 4.

Atonewell
  • 922
  • 4
  • 14