NPE when RESTEasy-Reactive and Picocli both in deps
See original GitHub issueDescribe the bug
If you have both RESTEasy-Reactive and Picocli in your dependencies, RESTEasy endpoints throws an NPE exception:
NullPointerException: Cannot invoke "io.quarkus.arc.ArcContainer.getActiveContext(java.lang.Class)" because the return value of "io.quarkus.arc.Arc.container()" is null
To reproduce, just create a new application at https://code.quarkus.io that has both RESTEasy-Reactive + Picocli, start it, and try to hit the /hello endpoint:

As an aside to the actual bug report – I am really curious what is happening here? These two things seem wildly unrelated, how is it that having Picocli in your deps could cause an error with RESTEasy Reactive 🤔
(It took me 30 minutes of trying different combinations of dependencies to figure out what the minimal reproduction/cause was)
java.lang.NullPointerException: Cannot invoke "io.quarkus.arc.ArcContainer.getActiveContext(java.lang.Class)" because the return value of "io.quarkus.arc.Arc.container()" is null
at io.quarkus.arc.runtime.devconsole.EventsMonitor_Observer_notify_513ab14b479908baeab956aa73f8a6221325887f.notify(Unknown Source)
at io.quarkus.arc.impl.EventImpl$Notifier.notifyObservers(EventImpl.java:320)
at io.quarkus.arc.impl.EventImpl$Notifier.notify(EventImpl.java:308)
at io.quarkus.arc.impl.EventImpl$Notifier.notify(EventImpl.java:238)
at io.quarkus.arc.impl.RequestContext.fireIfNotEmpty(RequestContext.java:209)
at io.quarkus.arc.impl.RequestContext.activate(RequestContext.java:123)
at io.quarkus.arc.ManagedContext.activate(ManagedContext.java:15)
at io.quarkus.resteasy.reactive.common.runtime.ArcThreadSetupAction.activateInitial(ArcThreadSetupAction.java:18)
at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.requireCDIRequestScope(AbstractResteasyReactiveContext.java:236)
at org.jboss.resteasy.reactive.server.handlers.InstanceHandler.handle(InstanceHandler.java:25)
at org.jboss.resteasy.reactive.server.handlers.InstanceHandler.handle(InstanceHandler.java:7)
at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:141)
at org.jboss.resteasy.reactive.server.handlers.RestInitialHandler.beginProcessing(RestInitialHandler.java:49)
at org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveVertxHandler.handle(ResteasyReactiveVertxHandler.java:17)
at org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveVertxHandler.handle(ResteasyReactiveVertxHandler.java:7)
at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1212)
at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:163)
at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:141)
at io.quarkus.vertx.http.runtime.StaticResourcesRecorder$2.handle(StaticResourcesRecorder.java:67)
at io.quarkus.vertx.http.runtime.StaticResourcesRecorder$2.handle(StaticResourcesRecorder.java:55)
at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1212)
at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:126)
at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:141)
at io.vertx.ext.web.handler.impl.StaticHandlerImpl.lambda$sendStatic$1(StaticHandlerImpl.java:274)
at io.vertx.core.impl.future.FutureImpl$3.onSuccess(FutureImpl.java:141)
at io.vertx.core.impl.future.FutureBase.lambda$emitSuccess$0(FutureBase.java:54)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:503)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:833)

Expected behavior
No response
Actual behavior
No response
How to Reproduce?
No response
Output of uname -a or ver
Microsoft Windows [Version 10.0.22000.376]
Output of java -version
OpenJDK Runtime Environment GraalVM CE 22.0.0-dev (build 17.0.2+5-jvmci-22.0-b02)
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.7.3-Final
Build tool (ie. output of mvnw --version or gradlew --version)
Gradle 7.3.3
Additional information
Have a great day 🙂
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (13 by maintainers)
Top Related StackOverflow Question
I’m gonna close this as it’s not a Quarkus issue.
Thanks everyone for your input
I think that this is not a common use case 😉. In this case, just use
Quarkus.waitForExit()as mentioned above.That’s probably because of how the dev mode works. In prod mode the app is just shut down. BTW you can press
spaceto run your command again.Just do: