IllegalAccessError: Module access


I tried upgrading our Java APM agent to version 1.18, but are getting a ton of error messages when booting up.

The application is running in docker using image adoptopenjdk/openjdk11-openj9:jdk-

Are there any additional steps i need to take when upgrading the application? Application is a Spring Boot application written in Kotlin using version 2.2.5.

java.lang.IllegalAccessError: Module 'java.base' no access to: package 'java.lang' because module 'java.base' can't read module 'unnamed module @61b4e073'
	at java.base/java.lang.invoke.MethodHandle.sendResolveMethodHandle(
	at java.base/java.lang.invoke.MethodHandle.getCPMethodHandleAt(Native Method)
	at java.base/java.lang.invoke.MethodHandle.resolveInvokeDynamic(
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor.schedule(
	at java.base/java.util.concurrent.Executors$
	at java.base/
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(
	at java.base/java.util.concurrent.ThreadPoolExecutor$
	at java.base/
Caused by: java.lang.IllegalAccessException: Module 'java.base' no access to: package 'java.lang' because module 'java.base' can't read module 'unnamed module @61b4e073'
	at java.base/java.lang.invoke.MethodHandles$Lookup.throwIllegalAccessException(
	at java.base/java.lang.invoke.MethodHandles$Lookup.checkClassModuleVisibility(
	at java.base/java.lang.invoke.MethodHandles$Lookup.checkClassAccess(
	at java.base/java.lang.invoke.MethodHandles$Lookup.checkAccess(
	at java.base/java.lang.invoke.MethodHandles$Lookup.checkAccess(
	at java.base/java.lang.invoke.MethodHandles$Lookup.findStatic(
	at java.base/java.lang.invoke.MethodHandle.sendResolveMethodHandle(
	... 10 more

Hi @joames, welcome to the forum.

The 1.18.0 version has a new way to instrument code, thus this seems to be an unexpected side effect.

Could you provide the JVM arguments that you are using to start the application ?
It looks like you are using java modules, thus it would help us reproduce and fix the issue.

Thanks in advance !

CMD java -noverify ${JAVA_OPTS} -javaagent:elastic-apm-agent.jar -jar app.jar

and JAVA_OPTS is an empty string

@joames what version did you upgrade from? Can you confirm this problem does not occur when using agent version 1.17.0?
Also, if your application is compatible for that, can you test agent version 1.18.0 with Java 10?

@Eyal_Koren i originally upgraded from 1.14 directly to 1.18, but had to downgrade to 1.17. Which is working correctly.

I can run a test with Java 10.

Awesome, this is extremely useful information. Thanks! :pray:

And are you using the sampling profiler - profiling_inferred_spans_enabled=true with 1.17.0?

No, only service name, environment application package and such.

We have opened an issue in our repository, you can subscribe to it to be notified when it will be fixed:

Building with docker image openjdk:10 and running with docker image adoptopenjdk/openjdk10:jdk- gives me a warning at start up.

unable to instantiate 'co.elastic.apm.agent.httpclient.HttpClientInstrumentation', unsupported class version error: co/elastic/apm/agent/httpclient/HttpClientInstrumentation has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 54.0

This warning is expected, as this plugin only works with Java11 and later, you can ignore it (and we fixed the proper log level to avoid it by default).

If not too much of a trouble, please try setting profiling_inferred_spans_enabled=true and see if you get the same error with 1.17.0.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

@joames We finally got the chance to tackle this issue. Please test this snapshot and see if it resolves the issue.

1 Like

Version 1.19.0 is released with a proposed fix for this issue.