Skip to content

IllegalAccessError with REST Resources outside of the application module #47744

@gsmet

Description

@gsmet

I'm having the same issue as the one described by @kevinross. In my case I have a @QuarkusTest calling the controller GreetingResource, the later being a package-private class found in another module.

In module A:

@QuarkusTest
// the issue appears no matter if this annotation is present
@TestHTTPEndpoint(GreetingResource.class)
class GreetingResourceTest {
	@Test
	void testHelloEndpoint() {...}
}

In module B:

@Path("/hello")
class GreetingResource {

    @GET
    public String hello() {...}
}

The above code will fail with a similar error:

2025-05-05 13:12:39,360 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-1) HTTP Request to /hello failed, error id: d1aab7de-f82a-43ac-bd36-d7719092e410-1: java.lang.IllegalAccessError: failed to access class org.acme.GreetingResource from class org.acme.GreetingResource$quarkusrestinvoker$hello_df324e1539083188359af68039a7afafb7b77cdb (org.acme.GreetingResource is in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @553f1d75; org.acme.GreetingResource$quarkusrestinvoker$hello_df324e1539083188359af68039a7afafb7b77cdb is in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @479ac2cb)
	at org.acme.GreetingResource$quarkusrestinvoker$hello_df324e1539083188359af68039a7afafb7b77cdb.invoke(Unknown Source)
	at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
	at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:141)
	at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
	at io.quarkus.vertx.core.runtime.VertxCoreRecorder$15.runWith(VertxCoreRecorder.java:637)
	at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)
	at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594)
	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/java.lang.Thread.run(Thread.java:1583)

Making GreetingResource public resolves the issue.

A reproducer can be found here:
classloader-issue.zip

Originally posted by @celcius112 in #47692

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions