question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SmallRye GraphQL and Hibernate Validator not works together in native

See original GitHub issue

Describe the bug add hibernate-validator and smallrye-graphql Set quarkus.smallrye-graphql.validation.enabled to true observe that hibernate validations doesnot runs and native app fails with exceptions

Expected behavior Expect that ‘smallrye-graphql’ use ‘hibernate-validator’ and native app not fail

Actual behavior hibernate validations not runs

To Reproduce

https://drive.google.com/file/d/1TzqBt3o7EYiK9l0jWba9SNBG2wkG-AgQ/view?usp=sharing

Steps to reproduce the behavior:

  1. add ‘hibernate-validator’ and ‘smallrye-graphql’
  2. Set ‘quarkus.smallrye-graphql.validation.enabled’ to true
  3. Create entity and pass it to mutations
class RegistrationRequest {
    @NotNull @Email lateinit var email: String
    @NotNull lateinit var password: String
    @NotNull lateinit var fistName: String
    @NotNull lateinit var lastName: String
    @Pattern(regexp = "^\\+(?:[0-9] ?){6,14}[0-9]\$")
    var phone: String? = null
}
    @Mutation
    fun register(@NotNull request: RegistrationRequest): Person {
        return personService.register(request)
    }
  1. observe that hibernate validations does not runs and native app fails with exceptions

Configuration

quarkus:
  smallrye-graphql:
    validation:
      enabled: true

Screenshots

__  ____  __  _____   ___  __ ____  ______ 
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ 
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \   
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/   
2020-12-09 15:18:20,355 INFO  [io.quarkus] (main) accounts 1.0.0-SNAPSHOT native (powered by Quarkus 1.10.3.Final) started in 0.026s. Listening on: http://0.0.0.0:8080
2020-12-09 15:18:20,355 INFO  [io.quarkus] (main) Profile prod activated. 
2020-12-09 15:18:20,355 INFO  [io.quarkus] (main) Installed features: [agroal, cdi, config-yaml, hibernate-validator, jdbc-postgresql, kotlin, mutiny, narayana-jta, security, smallrye-context-propagation, smallrye-graphql, smallrye-health, smallrye-jwt, vertx, vertx-web]
2020-12-09 15:18:26,489 ERROR [io.sma.graphql] (vert.x-worker-thread-0) SRGQL012000: Data Fetching Error: 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.smallrye.graphql.cdi.validation.ValidationService.beforeInvoke(ValidationService.java:28)
        at io.smallrye.graphql.execution.event.EventEmitter.fireBeforeMethodInvoke(EventEmitter.java:91)
        at io.smallrye.graphql.execution.datafetcher.helper.ReflectionHelper.invoke(ReflectionHelper.java:80)
        at io.smallrye.graphql.spi.datafetcher.DefaultWrapperHandlerService.invokeAndTransform(DefaultWrapperHandlerService.java:42)
        at io.smallrye.graphql.spi.datafetcher.AbstractWrapperHandlerService.getData(AbstractWrapperHandlerService.java:59)
        at io.smallrye.graphql.execution.datafetcher.PlugableDataFetcher.get(PlugableDataFetcher.java:34)
        at graphql.execution.instrumentation.dataloader.DataLoaderDispatcherInstrumentation.lambda$instrumentDataFetcher$0(DataLoaderDispatcherInstrumentation.java:86)
        at graphql.execution.ExecutionStrategy.fetchField(ExecutionStrategy.java:270)
        at graphql.execution.ExecutionStrategy.resolveFieldWithInfo(ExecutionStrategy.java:203)
        at graphql.execution.ExecutionStrategy.resolveField(ExecutionStrategy.java:177)
        at graphql.execution.AsyncSerialExecutionStrategy.lambda$execute$1(AsyncSerialExecutionStrategy.java:43)
        at graphql.execution.Async.eachSequentiallyImpl(Async.java:80)
        at graphql.execution.Async.eachSequentially(Async.java:69)
        at graphql.execution.AsyncSerialExecutionStrategy.execute(AsyncSerialExecutionStrategy.java:38)
        at graphql.execution.Execution.executeOperation(Execution.java:165)
        at graphql.execution.Execution.execute(Execution.java:104)
        at graphql.GraphQL.execute(GraphQL.java:557)
        at graphql.GraphQL.parseValidateAndExecute(GraphQL.java:482)
        at graphql.GraphQL.executeAsync(GraphQL.java:446)
        at graphql.GraphQL.execute(GraphQL.java:377)
        at io.smallrye.graphql.execution.ExecutionService.execute(ExecutionService.java:122)
        at io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLExecutionHandler.doRequest(SmallRyeGraphQLExecutionHandler.java:169)
        at io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLExecutionHandler.doRequest(SmallRyeGraphQLExecutionHandler.java:162)
        at io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLExecutionHandler.handlePost(SmallRyeGraphQLExecutionHandler.java:105)
        at io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLExecutionHandler.doHandle(SmallRyeGraphQLExecutionHandler.java:86)
        at io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLExecutionHandler.handle(SmallRyeGraphQLExecutionHandler.java:63)
        at io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLExecutionHandler.handle(SmallRyeGraphQLExecutionHandler.java:36)
        at io.vertx.ext.web.impl.BlockingHandlerDecorator.lambda$handle$0(BlockingHandlerDecorator.java:48)
        at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$2(ContextImpl.java:313)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.lang.Thread.run(Thread.java:834)
        at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:519)
        at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)

Environment (please complete the following information):

  • Output of uname -a or ver: Linux andrii-PC 5.4.0-56-generic #62-Ubuntu SMP Mon Nov 23 19:20:19 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
  • Output of java -version:
openjdk 11.0.9 2020-10-20
OpenJDK Runtime Environment GraalVM CE 20.3.0 (build 11.0.9+10-jvmci-20.3-b06)
OpenJDK 64-Bit Server VM GraalVM CE 20.3.0 (build 11.0.9+10-jvmci-20.3-b06, mixed mode, sharing)
  • GraalVM version (if different from Java):
  • Quarkus version or git rev: 1.10.3
  • Build tool (ie. output of mvnw --version or gradlew --version):
------------------------------------------------------------
Gradle 6.5.1
------------------------------------------------------------

Build time:   2020-06-30 06:32:47 UTC
Revision:     66bc713f7169626a7f0134bf452abde51550ea0a

Kotlin:       1.3.72
Groovy:       2.5.11
Ant:          Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM:          11.0.9 (GraalVM Community 11.0.9+10-jvmci-20.3-b06)
OS:           Linux 5.4.0-56-generic amd64

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
gsmetcommented, Dec 10, 2020

@phillip-kruger please add the backport label when you create the PR. I might release a 1.10.4.Final at some point.

0reactions
Andro999bcommented, Dec 10, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Validation with Hibernate Validator - Quarkus
This guide covers how to use Hibernate Validator/Bean Validation for: ... exists for GraphQL services based on the quarkus-smallrye-graphql extension.
Read more >
Home of Quarkus Cheat-Sheet - GitHub Pages
Quarkus uses Hibernate Validator to validate input/output of REST services and business services ... This does not work when using native image testing....
Read more >
Newest 'quarkus' Questions - Page 9 - Stack Overflow
I want to secure a GraphQL API using authentication against Keycloak. This works fine by using the "quarkus-oidc" extension as described in the...
Read more >
An Advanced GraphQL with Quarkus - Piotr's TechBlog
We need to include SmallRye GraphQL, Quarkus Panache, and the io.quarkus:quarkus-jdbc-h2 artifact ... Domain Model for GraphQL and Hibernate.
Read more >
Kogito Documentation - Red Hat on GitHub
Quarkus is native Java stack for Kubernetes that you can use to build ... Therefore, the Kogito process event add-on is not specifically...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found