After upgrading a reactive application from Spring Boot 3.1.5 to Spring Boot 3.2.0, I get the following error:
java.lang.IllegalStateException: No target Validator set
at org.springframework.util.Assert.state(Assert.java:76)
at org.springframework.validation.beanvalidation.SpringValidatorAdapter.forExecutables(SpringValidatorAdapter.java:396)
at org.springframework.validation.beanvalidation.MethodValidationAdapter.invokeValidatorForArguments(MethodValidationAdapter.java:257)
at org.springframework.validation.beanvalidation.MethodValidationAdapter.validateArguments(MethodValidationAdapter.java:240)
at org.springframework.web.method.annotation.HandlerMethodValidator.validateArguments(HandlerMethodValidator.java:115)
at org.springframework.web.method.annotation.HandlerMethodValidator.applyArgumentValidation(HandlerMethodValidator.java:83)
at org.springframework.web.reactive.result.method.InvocableHandlerMethod.lambda$invoke$0(InvocableHandlerMethod.java:164)
...
There is no other change in the code, the exception did not occur before in Spring Boot 3.1.5.
It is caused by a change of logic in the dependency on spring-boot-starter-validation. In my Spring Boot 3.1.5 applications, I either had not this dependency at all, or had it with the test scope. Now in spring Boot 3.2.0 it is apparently mandatory. The pom.xml file must contain
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
Without this, any controller method with parameters annotated with some jakarta.validation.* annotations, such as jakarta.validation.constraints.NotNull, throws the described exception. The exception is thrown by Spring and the method is not even called at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With