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

Resteasy tries to instantiate abstract classes since Quarkus 3.3 #41376

Closed
balta3 opened this issue Jun 23, 2024 · 2 comments · Fixed by #41465
Closed

Resteasy tries to instantiate abstract classes since Quarkus 3.3 #41376

balta3 opened this issue Jun 23, 2024 · 2 comments · Fixed by #41465
Labels
area/resteasy-classic kind/bug Something isn't working triage/needs-feedback We are waiting for feedback.
Milestone

Comments

@balta3
Copy link

balta3 commented Jun 23, 2024

Describe the bug

I use an abstract base class for the Rest Application class in an common library, Quarkus 3.3 is suddenly trying to instantiate this class, Quarkus 3.2 is working as intended.

As a workaround, set quarkus.resteasy.ignore-application-classes to true

Expected behavior

Resteasy should not try to instantiate abstract classes and simply ignore them.

Actual behavior

Resteasy tries to instantiate an abstract class, failing with an exception at startup:

2024-06-24 00:38:50,770 ERROR [io.qua.run.boo.StartupActionImpl] (Quarkus Main Thread) Error running Quarkus: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:104)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.ExceptionInInitializerError
	at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized0(Native Method)
	at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized(Unsafe.java:1160)
	at java.base/jdk.internal.reflect.MethodHandleAccessorFactory.ensureClassInitialized(MethodHandleAccessorFactory.java:300)
	at java.base/jdk.internal.reflect.MethodHandleAccessorFactory.newConstructorAccessor(MethodHandleAccessorFactory.java:103)
	at java.base/jdk.internal.reflect.ReflectionFactory.newConstructorAccessor(ReflectionFactory.java:200)
	at java.base/java.lang.reflect.Constructor.acquireConstructorAccessor(Constructor.java:549)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:70)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:124)
	at let.me.reproduce.Main.main(Main.java:10)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	... 3 more
Caused by: java.lang.RuntimeException: Failed to start quarkus
	at io.quarkus.runner.ApplicationImpl.<clinit>(Unknown Source)
	... 16 more
Caused by: java.lang.RuntimeException: RESTEASY003325: Failed to construct public let.me.reproduce.AbstractApplication()
	at org.jboss.resteasy.core.ConstructorInjectorImpl.constructOutsideRequest(ConstructorInjectorImpl.java:218)
	at org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:188)
	at io.quarkus.resteasy.common.runtime.QuarkusConstructorInjector.construct(QuarkusConstructorInjector.java:37)
	at org.jboss.resteasy.core.providerfactory.Utils.createProviderInstance(Utils.java:97)
	at org.jboss.resteasy.core.providerfactory.ResteasyProviderFactoryImpl.createProviderInstance(ResteasyProviderFactoryImpl.java:1265)
	at org.jboss.resteasy.core.ResteasyDeploymentImpl.createApplication(ResteasyDeploymentImpl.java:385)
	at org.jboss.resteasy.core.ResteasyDeploymentImpl.initializeObjects(ResteasyDeploymentImpl.java:239)
	at org.jboss.resteasy.core.ResteasyDeploymentImpl.startInternal(ResteasyDeploymentImpl.java:136)
	at org.jboss.resteasy.core.ResteasyDeploymentImpl.start(ResteasyDeploymentImpl.java:124)
	at io.quarkus.resteasy.runtime.standalone.ResteasyStandaloneRecorder.staticInit(ResteasyStandaloneRecorder.java:57)
	at io.quarkus.deployment.steps.ResteasyStandaloneBuildStep$staticInit345281060.deploy_0(Unknown Source)
	at io.quarkus.deployment.steps.ResteasyStandaloneBuildStep$staticInit345281060.deploy(Unknown Source)
	... 17 more
Caused by: java.lang.InstantiationException
	at java.base/jdk.internal.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:48)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
	at org.jboss.resteasy.core.ConstructorInjectorImpl.constructOutsideRequest(ConstructorInjectorImpl.java:203)
	... 28 more

How to Reproduce?

  1. Clone https://github.com/balta3/Quarkus-AbstractApplicationReproducer
  2. Run the application, it will fail to start
  3. To see this is a regression, set the Quarkus version to 3.2.12.Final and run the application, it will not fail to start

Output of uname -a or ver

Linux tuxsgaming 6.9.5-1-default #1 SMP PREEMPT_DYNAMIC Tue Jun 18 07:38:24 UTC 2024 (c9c2e24) x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "21.0.3" 2024-04-16 OpenJDK Runtime Environment (build 21.0.3+9-suse-1.1-x8664) OpenJDK 64-Bit Server VM (build 21.0.3+9-suse-1.1-x8664, mixed mode, sharing)

Quarkus version or git rev

3.3.3

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.9.8 Maven home: /usr/share/maven Java version: 21.0.3, vendor: N/A, runtime: /usr/lib64/jvm/java-21-openjdk-21 Default locale: de_DE, platform encoding: UTF-8 OS name: "linux", version: "6.9.5-1-default", arch: "amd64", family: "unix"

Additional information

No response

@geoand
Copy link
Contributor

geoand commented Jun 26, 2024

Thanks for reporting.

The attached reproducer does not work at all unfortunately... It does not seem to be a properly configured Quarkus application

@geoand
Copy link
Contributor

geoand commented Jun 26, 2024

In any case, #41465 fixes the issue

geoand added a commit that referenced this issue Jun 26, 2024
Ignore abstract jakarta.ws.rs.core.Application classes
@quarkus-bot quarkus-bot bot added this to the 3.13 - main milestone Jun 26, 2024
@gsmet gsmet modified the milestones: 3.13 - main, 3.12.1 Jun 26, 2024
gsmet pushed a commit to gsmet/quarkus that referenced this issue Jun 26, 2024
holly-cummins pushed a commit to holly-cummins/quarkus that referenced this issue Jul 31, 2024
@gsmet gsmet modified the milestones: 3.12.1, 3.8.6 Aug 14, 2024
gsmet pushed a commit to gsmet/quarkus that referenced this issue Aug 14, 2024
danielsoro pushed a commit to danielsoro/quarkus that referenced this issue Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/resteasy-classic kind/bug Something isn't working triage/needs-feedback We are waiting for feedback.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants