Search code examples
springhibernate-validator

Method-level validation in Spring 3.2.3 with Hibernate Validator 5.0.0.final


I have enabled method level validation in service class. However I got java.lang.NoClassDefFoundError during startup of the application. Anyone know the workaround solution for this issue:

Caused by: java.lang.NoClassDefFoundError: org/hibernate/validator/method/MethodConstraintViolationException
    at org.springframework.validation.beanvalidation.MethodValidationPostProcessor.afterPropertiesSet(MethodValidationPostProcessor.java:102)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
    ... 55 more

Solution

  • Hibernate 5 custom integration will be supported only with the upcoming Spring 4 (https://jira.springsource.org/browse/SPR-10466).

    If you really want to use Hibernate 5, you will need to use it as standard JSR 303 bean validation provider with the standard message interpolation mechanism (i.e. no integration with MessageSource, but standard ValidationMessages.properties).