Skip to content

mvc:annotation-driven incorrectly detects validation provider on classpath [SPR-11272] #15897

@spring-projects-issues

Description

@spring-projects-issues

John Mark opened SPR-11272 and commented

I currently have javax.validation:validation-api:1.1.0.Final on my classpath since I include an artifact that uses that jar. Spring seems to detect this and try to create a validator using org.springframework.validation.beanvalidation.LocalValidatorFactoryBean which then fails since I don't have a validation provider like Hibernate Validator on my classpath. This then causes my entire webapp to fail to start.

This behavior does not make sense to me. If I don't have a validation provider on my classpath, then why does Spring think I want to use validation? I would think that mvc:annotation-driven should use the same type of detection mechanism that LocalValidatorFactoryBean uses to determine if a validation provider is on the classpath. That way it wouldn't try to create a validator just because I have the validation API on my classpath. It should only try to create a validator if a provider implementation exists. According to the documentation at http://docs.spring.io/spring-framework/docs/current/spring-framework-reference/html/mvc.html (Section 16.1.1) mvc:annotation-driven/ should only enable validation if a JSR-303 Provider is present on the classpath.


Affects: 4.0 GA

Issue Links:

Referenced from: commits b9c8f47, 6a5a3c9, e334489, 6aabb5f, c48da0d, 8d1e55d

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions