javax.validation.ValidationException: Unable to create a Configuration, because no Bean Validation provider could be found

I was working on writing JSR 303 Custom Validation to validate Email Address and encountered with following exception.

javax.validation.ValidationException: Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.
    at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:271)
    at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:110)
    at com.anuj.core.test.ValidEmailTest.setUp(ValidEmailTest.java:21)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)

 In order to solve this exception, I have added hibernate-validator-4.2.0.Final.jar to Build Path and Issue resolved !

If you are using Maven then Pom Entry for hibernate-validator will be as follows :
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-validator</artifactId>
    <version>4.2.0.Final</version>
</dependency>

No comments:

Post a Comment