You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.
If I add the hibernate-validators dependency on a reactive webflux project and use the standard validation annotations like javax.validation.Valid on @RestController endpoints for validating beans with constrains like javax.validation.constraints.NotNull I see the following error on requests on those endpoints:
Failed to instantiate [org.hibernate.validator.internal.constraintvalidators.bv.NotNullValidator]: No default constructor found;
Worst part is, it returns HTTP-200 instead of a 5xx response due to the reactive nature (I suppose) of the application.
Here is the full DEBUG log of the request
DEBUG 1 --- [ctor-http-nio-4] o.s.w.s.adapter.HttpWebHandlerAdapter : [8ed1577c-3] HTTP POST "/products"
DEBUG 1 --- [ctor-http-nio-4] s.w.r.r.m.a.RequestMappingHandlerMapping : [8ed1577c-3] Mapped to com.example.ProductController#create(Product)
DEBUG 1 --- [ctor-http-nio-4] .r.m.a.RequestBodyMethodArgumentResolver : [8ed1577c-3] Content-Type:application/json
DEBUG 1 --- [ctor-http-nio-4] .r.m.a.RequestBodyMethodArgumentResolver : [8ed1577c-3] 0..1 [com.example.Product]
DEBUG 1 --- [ctor-http-nio-4] o.s.http.codec.json.Jackson2JsonDecoder : [8ed1577c-3] Decoded [Product{id=null, name=aaaa, code=1111}]
DEBUG 1 --- [ctor-http-nio-4] o.s.web.method.HandlerMethod : [8ed1577c-3] Could not resolve parameter [0] in public reactor.core.publisher.Mono<com.example.Product> com.example.ProductController.create(com.example.Product): Error creating bean with name 'org.hibernate.validator.internal.constraintvalidators.bv.NotNullValidator': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.hibernate.validator.internal.constraintvalidators.bv.NotNullValidator]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.hibernate.validator.internal.constraintvalidators.bv.NotNullValidator.<init>()
DEBUG 1 --- [ctor-http-nio-4] o.s.w.s.adapter.HttpWebHandlerAdapter : [8ed1577c-3] Completed 200 OK
If I provide the following reflect-config.json it works:
ValidationHints.java already provides some hints but I think it's not complete and further hints should be provided for all *Validator classes under org.hibernate.validator.internal.constraintvalidators and it's sub-packages.
Complementary note, I also see a ClassNotFoundException: org.hibernate.validator.messageinterpolation.ParameterMessageInterpolator error on this sample (modified to use @SpringBootApplication instead of @Configuration on the main class).
Hello everyone,
If I add the hibernate-validators dependency on a reactive webflux project and use the standard validation annotations like
javax.validation.Valid
on@RestController
endpoints for validating beans with constrains likejavax.validation.constraints.NotNull
I see the following error on requests on those endpoints:Failed to instantiate [org.hibernate.validator.internal.constraintvalidators.bv.NotNullValidator]: No default constructor found;
Worst part is, it returns
HTTP-200
instead of a5xx
response due to the reactive nature (I suppose) of the application.Here is the full
DEBUG
log of the requestIf I provide the following
reflect-config.json
it works:DEBUG
log for the working endpoint after providing thereflect-config.json
ValidationHints.java already provides some hints but I think it's not complete and further hints should be provided for all
*Validator
classes underorg.hibernate.validator.internal.constraintvalidators
and it's sub-packages.Here is the full-example with the
reflect-config.json
:https://github.com/hakandilek/spring-native-sample/tree/hibernate-constraintvalidators
The text was updated successfully, but these errors were encountered: