Description
When setting up a Spring Web MVC application, if I have Hibernate Validator on the classpath I am supposed to have a validator available in Spring context to make bean validation work.
However, using Spring Framework 6.2.0 and Hibernate Validator 8.0.1, if I also don't have an EL implementation in my classpath, it happens that org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet()
throws a ValidationException
and org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean.afterPropertiesSet()
suppresses it by just emitting a debug-level log message, reporting the inability to set up a Bean Validation provider.
The exception that is thrown by Hibernate Validator in this case is a ValidationException
with a cause of type NoClassDefFoundError
and the following message:
HV000183: Unable to initialize 'jakarta.el.ExpressionFactory'. Check that you have the EL dependencies on the classpath, or use ParameterMessageInterpolator instead
It took me a while to understand why validation was not working, and it was due to neither Hibernate Validator nor Spring Framework giving me any warning or error (log verbosity was set to INFO). This is probably a typical case of error when setting up Hibernate Validator, yet (or even more so) I would have appreciated some error reporting.