Quarkus REST in NATIVE - abstract resources with @Path requires impl. to be CDI beans while RESTEasy does not #42976
Description
Describe the bug
Quarkus REST in NATIVE - abstract resources with @Path
requires impl. to be CDI beans while RESTEasy does not
This is basically #41567 for NATIVE mode.
#41606 fixed the issue for JVM mode, but NATIVE is still broken, stacktrace appears after first request.
target/app-1.0.0-SNAPSHOT-runner
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2024-09-02 23:43:45,430 INFO [io.quarkus] (main) app 1.0.0-SNAPSHOT native (powered by Quarkus 999-SNAPSHOT) started in 2.767s. Listening on: http://0.0.0.0:8080
2024-09-02 23:43:45,430 INFO [io.quarkus] (main) Profile prod activated.
2024-09-02 23:43:45,430 INFO [io.quarkus] (main) Installed features: [cdi, rest, smallrye-context-propagation, vertx]
2024-09-02 23:43:52,344 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-1) HTTP Request to /hello failed, error id: 2061ff63-7e62-4ace-8e5b-1103e212d2f9-1: java.lang.IllegalArgumentException: Unable to create class 'org.acme.GreetingResource'. To fix the problem, make sure this class is a CDI bean.
at io.quarkus.resteasy.reactive.common.runtime.ArcBeanFactory.createInstance(ArcBeanFactory.java:41)
at org.jboss.resteasy.reactive.server.handlers.InstanceHandler.handle(InstanceHandler.java:26)
at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:139)
at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:635)
at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base@21.0.2/java.lang.Thread.runWith(Thread.java:1596)
at java.base@21.0.2/java.lang.Thread.run(Thread.java:1583)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:833)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:211)
Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException: org.acme.GreetingResource.<init>()
at io.quarkus.arc.runtime.BeanContainerImpl$DefaultInstanceFactory.create(BeanContainerImpl.java:107)
at io.quarkus.resteasy.reactive.common.runtime.ArcBeanFactory.createInstance(ArcBeanFactory.java:27)
... 14 more
Caused by: java.lang.NoSuchMethodException: org.acme.GreetingResource.<init>()
at java.base@21.0.2/java.lang.Class.checkMethod(DynamicHub.java:1075)
at java.base@21.0.2/java.lang.Class.getConstructor0(DynamicHub.java:1238)
at java.base@21.0.2/java.lang.Class.getDeclaredConstructor(DynamicHub.java:2930)
at io.quarkus.arc.runtime.BeanContainerImpl$DefaultInstanceFactory.create(BeanContainerImpl.java:99)
... 15 more
2024-09-02 23:44:09,163 INFO [io.quarkus] (Shutdown thread) app stopped in 0.002s
Expected behavior
The same behavior as in JVM mode.
Actual behavior
2024-09-02 23:43:52,344 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-1) HTTP Request to /hello failed, error id: 2061ff63-7e62-4ace-8e5b-1103e212d2f9-1: java.lang.IllegalArgumentException: Unable to create class 'org.acme.GreetingResource'. To fix the problem, make sure this class is a CDI bean.
is thrown
How to Reproduce?
sdk use java 21.0.2-graalce
## or equivalent for Mandrelgit clone git@github.com:michalvavrik/abstract-quarkus-rest-repro.git
cd abstract-quarkus-rest-repro
mvn clean verify -Dnative -Dquarkus.platform.group-id=io.quarkus -Dquarkus.platform.version=999-SNAPSHOT
After switching <artifactId>quarkus-rest</artifactId>
to <artifactId>quarkus-resteasy</artifactId>
the app works well.
Output of uname -a
or ver
macOS
Output of java -version
Java 21
Quarkus version or git rev
Quarkus main / Quarkus 3.14.1
Build tool (ie. output of mvnw --version
or gradlew --version
)
No response
Additional information
No response