quarkus
quarkus copied to clipboard
NPE in REST endpoint generated by hibernate-orm-rest-data-panache in Gradle project
Describe the bug
This is a regression likely introduced by https://github.com/quarkusio/quarkus/commit/827f778c9ab71478b19ce230ac5a5265bfdba592 (confirmed locally by building and using the snapshot).
In a Gradle project that uses the quarkus-hibernate-orm-rest-data-panache
, a generated REST resource, that is supposed to add a new entity, throws an NPE:
Cannot invoke "io.quarkus.hal.HalService.getSelfLink(Object)" because the return value of "io.quarkus.arc.InstanceHandle.get()" is null
(see the attached complete stacktrace)
- the same project based on maven works
- downgrading the Quarkus Gradle plugin to 2.13.0.Final also works (the regression was introduced in 2.13.1.Final)
Expected behavior
Pass the test in the linked reproducer.
Actual behavior
NPE during test execution.
How to Reproduce?
https://github.com/rsynek/gradle-panache-reproducer
Output of uname -a
or ver
No response
Output of java -version
No response
GraalVM version (if different from Java)
No response
Quarkus version or git rev
No response
Build tool (ie. output of mvnw --version
or gradlew --version
)
Gradle
Additional information
io.quarkus.rest.data.panache.RestDataPanacheException: Failed to add an entity at org.acme.rest.LessonResourceJaxRs_18d582de9c337f470959119eaac78d737bfa8a09.add(Unknown Source) at [email protected]/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at [email protected]/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at [email protected]/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at [email protected]/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:564) 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 [email protected]/java.lang.Thread.run(Thread.java:833) Caused by: java.lang.NullPointerException: Cannot invoke "io.quarkus.hal.HalService.getSelfLink(Object)" because the return value of "io.quarkus.arc.InstanceHandle.get()" is null ... 31 more
/cc @FroMage, @Sanne, @glefloch, @gsmet, @loicmathieu, @quarkusio/devtools, @yrodiere
Thanks for reporting this @rsynek, I think the issue will be resolved with #28440
same over here:
thanks for report and fix
Closing as a duplicate of https://github.com/quarkusio/quarkus/issues/28440.
The workaround for now is to add io.quarkus:quarkus-resteasy-reactive-kotlin
as a dependency explicitly.
Caused by: java.lang.NullPointerException: Cannot invoke "io.quarkus.hal.HalService.getSelfLink(Object)" because the return value of "io.quarkus.arc.InstanceHandle.get()" is null
the dependency does not fix the issue plus this seems to be an fishy workaround, we dont need that module before why should we add it then?


dont seems to be an general issue, the other project is more complex, panache and more maybe thats some hint:
