Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quarkus REST in NATIVE - abstract resources with @Path requires impl. to be CDI beans while RESTEasy does not #42976

Open
rsvoboda opened this issue Sep 3, 2024 · 4 comments
Labels
area/arc Issue related to ARC (dependency injection) area/native-image area/rest kind/bug Something isn't working

Comments

@rsvoboda
Copy link
Member

rsvoboda commented Sep 3, 2024

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 [email protected]/java.lang.Thread.runWith(Thread.java:1596)
	at [email protected]/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 [email protected]/java.lang.Class.checkMethod(DynamicHub.java:1075)
	at [email protected]/java.lang.Class.getConstructor0(DynamicHub.java:1238)
	at [email protected]/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?

  1. sdk use java 21.0.2-graalce ## or equivalent for Mandrel
  2. git clone [email protected]:michalvavrik/abstract-quarkus-rest-repro.git
  3. cd abstract-quarkus-rest-repro
  4. 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

@rsvoboda rsvoboda added the kind/bug Something isn't working label Sep 3, 2024
@quarkus-bot quarkus-bot bot added area/arc Issue related to ARC (dependency injection) area/native-image labels Sep 3, 2024
Copy link

quarkus-bot bot commented Sep 3, 2024

/cc @Karm (mandrel), @Ladicek (arc), @galderz (mandrel), @manovotn (arc), @mkouba (arc), @zakkak (mandrel,native-image)

@rsvoboda
Copy link
Member Author

rsvoboda commented Sep 3, 2024

/cc @geoand

@geoand
Copy link
Contributor

geoand commented Sep 3, 2024

cc @michalvavrik

@michalvavrik
Copy link
Member

Good catch, as we know there will be just one subclass and it will be instantiated, be should probably register it for reflection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/arc Issue related to ARC (dependency injection) area/native-image area/rest kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants