I have read this and this, but that didn't help...
I am using hibernate validator with the following versions/dependencies:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.4.1.FINAL</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<version>3.0.1-b08</version>
</dependency>
I thought I'm doing everything correctly, and my logs (with verbose:class as a flag) tell me that:
[Loaded org.hibernate.validator.internal.engine.ConfigurationImpl from file:.../hibernate-validator-5.4.1.Final.jar]
[Loaded javax.validation.Validation from file:.../validation-api-1.1.0.Final.jar]
But later at runtime, when I use
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
I get the classic error:
java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.ConfigurationImpl
I also tried downgrading to hibernate-validator 4.3.1 and javax.validation-api 1.0.0, but the error weirdly enough remained the same.
I have loads of other dependencies in this project(e.g. Spring etc.) , but as far as I can see, none that use hibernate-validator or the javax validation api. (If that were the case, I'd also see them loaded in the logs, wouldn't I?)
Is there any help?
This problem is due to incorrect version of “ hibernate-validator ” dependency. You need to try other versions of this dependency to solve this issue. In my example, following combination works perfectly. My spring MVC example application uses below pom.xml for our reference.
This kind of error is usually related to class loading issues that prevents a JAR being loaded. Check if you have all required libraries in the CLASSPATH. Show activity on this post. first try to add these .jar slf4j-api.jar and slf4j-log4j12.jar because hibernate internally use these jar.
If you are trying to setup your project/ or adding dependency for hibernate 4 then you might face this error in your server logs. Reason is that you have incompatible jar’s versions in your application classpath.
If you are trying to setup your project/ or adding dependency for hibernate 4 then you might face this error in your server logs. Reason is that you have incompatible jar’s versions in your application classpath. To resolve this issue, make sure you have compatible jars. Sample configuration for hibernate 4 will be as below.
For me the problem was that Hibernate Validator depended on jboss-logging. And the jboss logging was not part of my classpath. The exception was not telling me that the class not def found error while trying to instantiate the hibernate configuration impl was from missing jboss logging on the classpath.
Once I added it to the classpath, the class def not found error went away.
I was facing the same issue while working with JSR 303 bean validation I have added below two jar(along with validation-api-1.1.0.final.jar and hibernate-validator-5.0.1.final.jar) and the issue got resolved
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With