'UnexpectedTypeException: HV000030: No validator could be found for constraint 'javax.validation.constraints.Size' validating type 'java.lang.String'
I am getting this error when running integration tests for an endpoint in Quarkus. I make a POST request passing a valid object as body. Method signature:
@POST
public Response myMethodPost(@Valid MyObjData myObjData);
I get the following error:
javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint 'javax.validation.constraints.Size' validating type 'java.lang.String'. Check configuration for 'myMethodPost.arg0.dataId'
Where dataId is a property of MyObjData of type String.
I have also included the following Maven dependencies:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
Solution 1:[1]
Quarkus won't scan classes that are in other modules or jars, so it fails to register the validators at start up.
I had to add the org.kordamp.gradle.jandex gradle plugin to my submodule in order for Quarkus to see the annations.
Discussion here: https://github.com/quarkusio/quarkus/issues/13233
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | KevinC |
