roxhens
roxhens

Reputation: 552

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>

Upvotes: 1

Views: 879

Answers (1)

KevinC
KevinC

Reputation: 335

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

Upvotes: 3

Related Questions