Exception encountered during context initialization – cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sessionFactory’ defined in class path resource [xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/validation/ValidatorFactory

The above error is quite obvious that javax.validation is missing. To fix this issue, we would need to import hibernate validator.

Here is the dependency to be added to the pom.

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.2.1.Final</version>
</dependency>

Make sure that the version defined above is compatible with hibernate core.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.