javax.validation.NoProviderFoundException error in a native executable
See original GitHub issueDescribe the bug
We are developing a Quarkus application to be used in a Serverless design (coordinated with Knative Brokers and Triggers) exposing a REST API with validations that it is working successfully in JVM mode, however it is not working with native mode.
The REST API exposes endpoints with DTO objects, integrated with validations, however, when we tested as native we are getting this error:
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2022-11-11 14:18:20,214 INFO [io.qua.sma.ope.run.OpenApiRecorder] (main) Default CORS properties will be used, please use 'quarkus.http.cors' properties instead
2022-11-11 14:18:20,219 INFO [io.quarkus] (main) event-producer 2.10.1-SNAPSHOT native (powered by Quarkus 2.10.1.Final) started in 0.023s. Listening on: http://0.0.0.0:8080
2022-11-11 14:18:20,219 INFO [io.quarkus] (main) Profile prod activated.
2022-11-11 14:18:20,219 INFO [io.quarkus] (main) Installed features: [cdi, hibernate-validator, kubernetes, rest-client, resteasy, resteasy-jsonb, smallrye-context-propagation, smallrye-health, smallrye-openapi, swagger-ui, vertx]
2022-11-11 14:18:21,364 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-0) HTTP Request to /event-producer/sourcesystemcall/initial failed, error id: be4198a5-d25d-4fd6-8785-de3dd08b2e57-1: javax.validation.NoProviderFoundException: Unable to create a Configuration, because no Jakarta Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.
at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:291)
at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:103)
at io.cloudevents.v03.CloudEventBuilder.getValidator(CloudEventBuilder.java:73)
at io.cloudevents.v03.CloudEventBuilder.build(CloudEventBuilder.java:177)
at com.redhat.eda.processor.service.SourceSystemCallEventService.publishEvent(SourceSystemCallEventService.java:63)
at com.redhat.eda.processor.service.SourceSystemCallEventService_Subclass.publishEvent$$superforward1(Unknown Source)
at com.redhat.eda.processor.service.SourceSystemCallEventService_Subclass$$function$$1.apply(Unknown Source)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:53)
at io.quarkus.hibernate.validator.runtime.interceptor.AbstractMethodValidationInterceptor.validateMethodInvocation(AbstractMethodValidationInterceptor.java:68)
at io.quarkus.hibernate.validator.runtime.interceptor.MethodValidationInterceptor.validateMethodInvocation(MethodValidationInterceptor.java:17)
at io.quarkus.hibernate.validator.runtime.interceptor.MethodValidationInterceptor_Bean.intercept(Unknown Source)
at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:40)
at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
at com.redhat.eda.processor.service.SourceSystemCallEventService_Subclass.publishEvent(Unknown Source)
at com.redhat.eda.processor.service.SourceSystemCallEventService_ClientProxy.publishEvent(Unknown Source)
at com.redhat.eda.processor.api.SourceSystemCallEventProducer.publishInitialEvent(SourceSystemCallEventProducer.java:60)
at com.redhat.eda.processor.api.SourceSystemCallEventProducer_Subclass.publishInitialEvent$$superforward1(Unknown Source)
at com.redhat.eda.processor.api.SourceSystemCallEventProducer_Subclass$$function$$1.apply(Unknown Source)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:53)
at io.quarkus.hibernate.validator.runtime.interceptor.AbstractMethodValidationInterceptor.validateMethodInvocation(AbstractMethodValidationInterceptor.java:68)
at io.quarkus.hibernate.validator.runtime.jaxrs.JaxrsEndPointValidationInterceptor.validateMethodInvocation(JaxrsEndPointValidationInterceptor.java:35)
at io.quarkus.hibernate.validator.runtime.jaxrs.JaxrsEndPointValidationInterceptor_Bean.intercept(Unknown Source)
at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:40)
at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
at com.redhat.eda.processor.api.SourceSystemCallEventProducer_Subclass.publishInitialEvent(Unknown Source)
at java.lang.reflect.Method.invoke(Method.java:568)
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:170)
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:660)
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:524)
at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:474)
at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:476)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:434)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:408)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:69)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:492)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:151)
at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:91)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:555)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:833)
at com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:704)
at com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:202)
We found that there are some references around this issue:
- https://github.com/quarkusio/quarkus/discussions/24372
- https://github.com/quarkusio/quarkus/pull/29205
But it is not working in our case.
One of the endpoints exposed are similar to:
@Path("/call/initial")
@POST
public Response publishInitialEvent(
@Valid @Parameter(description = "Call Event", required = true) EventDTO eventDTO) {
// Business implementation
}
The DTO is similar to:
@XmlRootElement
@RegisterForReflection(serialization = true)
public class EventDTO implements Serializable {
private static final long serialVersionUID = 1305278483346223763L;
@Schema(description = "Call UUID", required = true, example = "32d4c1f3-55df-4704-a34c-ba4b2c02039d")
@NotNull(message = "Call UUID value should be not null")
@NotBlank(message="Call UUID may not be blank")
private String callUUID;
// Getters/Setters
}
Expected behavior
Execution correctly, including the validations.
Actual behavior
No response
How to Reproduce?
Implement a REST API endpoint using Validators and testing with the native mode.
Output of uname -a
or ver
Linux redhat 6.0.5-200.fc36.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Oct 26 15:55:21 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Output of java -version
openjdk version “17.0.5” 2022-10-18 OpenJDK Runtime Environment (Red_Hat-17.0.5.0.8-2.fc36) (build 17.0.5+8) OpenJDK 64-Bit Server VM (Red_Hat-17.0.5.0.8-2.fc36) (build 17.0.5+8, mixed mode, sharing)
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.14.0.Final
Build tool (ie. output of mvnw --version
or gradlew --version
)
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Additional information
No response
Issue Analytics
- State:
- Created 10 months ago
- Comments:11 (9 by maintainers)
To me this is a “hibernate-validator” + “cloudevents-api” issue. More in detail the issue is here:
Looks that for some internal issue “CloudEvent” is not able to get an instance of Quarkus Validator (
javax.validation.Validator
). So maybe as a workaround you could inject the validator by your self and then use it in the cloudEvents builderI think that this patch could work until the issue fixed 😃
Probably a good idea to have a check if the ArC container is started and throw an exception if not.