Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OptionalValidatorFactoryBean suppresses Hibernate Validator configuration failures too much #33979

Closed
mauromol opened this issue Nov 27, 2024 · 0 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement
Milestone

Comments

@mauromol
Copy link

mauromol commented Nov 27, 2024

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Nov 27, 2024
@jhoeller jhoeller added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Dec 6, 2024
@jhoeller jhoeller self-assigned this Dec 6, 2024
@jhoeller jhoeller added this to the 6.2.1 milestone Dec 6, 2024
@jhoeller jhoeller added the for: backport-to-6.1.x Marks an issue as a candidate for backport to 6.1.x label Dec 6, 2024
@github-actions github-actions bot added status: backported An issue that has been backported to maintenance branches and removed for: backport-to-6.1.x Marks an issue as a candidate for backport to 6.1.x labels Dec 6, 2024
jhoeller added a commit that referenced this issue Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants