I was trying to upgrade quarkus from 1.x to 3.6.3
In 3.6.3 I have to introduce the dependency 'io.quarkus:quarkus-hibernate-validator'
to support jakarta.validation.constraints.*
.
Then I got this build error:
java.lang.RuntimeException: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.hibernate.validator.deployment.HibernateValidatorProcessor#beanValidationAnnotations threw an exception: java.lang.NoSuchMethodError: 'java.util.Set org.hibernate.validator.internal.metadata.core.ConstraintHelper.getBuiltinConstraints()'
at io.quarkus.hibernate.validator.deployment.HibernateValidatorProcessor.beanValidationAnnotations(HibernateValidatorProcessor.java:176)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:849)
at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
at java.base/java.lang.Thread.run(Thread.java:840)
at org.jboss.threads.JBossThread.run(JBossThread.java:501)
at io.quarkus.test.junit.QuarkusTestExtension.throwBootFailureException(QuarkusTestExtension.java:638)
at io.quarkus.test.junit.QuarkusTestExtension.interceptTestClassConstructor(QuarkusTestExtension.java:722)
at java.base/java.util.Optional.orElseGet(Optional.java:364)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
In my API definition, I've noticed that the validations were applied to @NotNull @Valid Set<Long> requestBody
(generated by OpenAPI). I am not sure the error means hibernate does not find any validator for Set
class?
There is a transitive dependency of Hibernate validator. After I exclude it from gradle build, the problem is resolved.