Skip to content

OptionalValidatorFactoryBean suppresses Hibernate Validator configuration failures too much #33979

Closed
@mauromol

Description

@mauromol

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.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions