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

IllegalAccessError invoking non-public @Scheduled method #17492

Closed
jimbogithub opened this issue May 27, 2021 · 4 comments · Fixed by #17495
Closed

IllegalAccessError invoking non-public @Scheduled method #17492

jimbogithub opened this issue May 27, 2021 · 4 comments · Fixed by #17495
Assignees
Labels
Milestone

Comments

@jimbogithub
Copy link

Describe the bug

An IllegalAccessError is thrown when invoking a non-public @scheduled method, e.g:

@scheduled(every = "PT10S", concurrentExecution = ConcurrentExecution.SKIP)
void myMethod() {...}

All is fine if the method is public.

Call stack looks like so:

2021-05-27 15:58:27,006 ERROR (executor-thread-2) [SimpleScheduler] Error occured while executing task for trigger IntervalTrigger [id=1_my.redacted.Service_ScheduledInvoker_myMethod_8d0ea617bdcf7cab33987d918fbaeabfd51940d4, interval=10000]
java.lang.IllegalAccessError: class my.redacted.Service_ScheduledInvoker_myMethod_8d0ea617bdcf7cab33987d918fbaeabfd51940d4 tried to access method my.redacted.Service.myMethod()V (my.redacted.Service_ScheduledInvoker_myMethod_8d0ea617bdcf7cab33987d918fbaeabfd51940d4 is in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @451b1c01; my.redacted.Service is in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @6f45da6b)
at my.redacted.Service_ScheduledInvoker_myMethod_8d0ea617bdcf7cab33987d918fbaeabfd51940d4.invokeBean(Service_ScheduledInvoker_myMethod_8d0ea617bdcf7cab33987d918fbaeabfd51940d4.zig:46)
at io.quarkus.arc.runtime.BeanInvoker.invoke(BeanInvoker.java:20)
at io.quarkus.scheduler.runtime.SkipConcurrentExecutionInvoker.invoke(SkipConcurrentExecutionInvoker.java:37)
at io.quarkus.scheduler.runtime.SkipConcurrentExecutionInvoker.invoke(SkipConcurrentExecutionInvoker.java:19)
at io.quarkus.scheduler.runtime.SimpleScheduler$ScheduledTask$1.run(SimpleScheduler.java:251)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:486)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2442)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1450)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:834)

Expected behavior

Expect it to work ok with default access per other Quarkus/CDI methods.

Actual behavior

Fails with IllegalAccessError.

Quarkus version or git rev

2.0.0.CR1

@jimbogithub jimbogithub added the kind/bug Something isn't working label May 27, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented May 27, 2021

/cc @mkouba

@mkouba mkouba self-assigned this May 27, 2021
@mkouba
Copy link
Contributor

mkouba commented May 27, 2021

Hello @jimbogithub, could you describe your application structure in more detail? We use the package-private @Scheduled methods in the tests and in the quickstart without any problem. Private methods are not supported.

It seems that the invoker class and the service class are loaded by a different class loader. Isn't the my.redacted.Service class located in a shared library, i.e. outside the application src/main/java?

mkouba added a commit to mkouba/quarkus that referenced this issue May 27, 2021
- until now all invokers were considered application classes, i.e. they
were always loaded by the Runtime Class Loader in the dev mode and so a
package-private scheduled method defined in a dependency resulted in an
IllegalAccessError
- resolves quarkusio#17492
@quarkus-bot quarkus-bot bot added this to the 2.0 - main milestone May 27, 2021
@gsmet gsmet modified the milestones: 2.1 - main, 2.0.0.CR2 May 27, 2021
gsmet pushed a commit that referenced this issue May 27, 2021
- until now all invokers were considered application classes, i.e. they
were always loaded by the Runtime Class Loader in the dev mode and so a
package-private scheduled method defined in a dependency resulted in an
IllegalAccessError
- resolves #17492

(cherry picked from commit a5acdc9)
@jimbogithub
Copy link
Author

Hello @jimbogithub, could you describe your application structure in more detail? We use the package-private @Scheduled methods in the tests and in the quickstart without any problem. Private methods are not supported.

It seems that the invoker class and the service class are loaded by a different class loader. Isn't the my.redacted.Service class located in a shared library, i.e. outside the application src/main/java?

Yes, you're correct, the my.redacted.Service class is located in a shared library (actually just a test dependency in this case as part of a semi-integration test of two interrelated modules).

Looks like you have the fix, thanks.

@jimbogithub
Copy link
Author

Confirmed fixed for me in 2.0.0.CR2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants