Hello,
I'm using the bean validation API and its implementation provided by Hibernate validator for the first time.
I've setup my project using maven. I've put the following dependencies amongst others:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>3.1.0.GA</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
Then I annotated one of my classes with the JSR 303 annotations, created an instance of it and tried to validate it. But the following method failed:
Code:
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
The exact exception is:
Code:
javax.validation.ValidationException: Unable to find a default provider
at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:264)
at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:111)
After reading some forums I understood that a JSR 303 implementation should be in my classpath. I have it - hibernate-validator. Next I did some debugging and found that my hibernate-validator jar is missing META-INF/services/javax.validation.spi.ValidationProvider file and thus the validator resolver cannot find which is the exact implementation to instantiate.
Could you help me with this? It seems that it's only me in the whole internet, that has this problem, so apparently I'm doing something wrong. :-)
Thanks,
Ivan