IllegalAccessError: Module access

Hi,

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-11.0.1.13-alpine-slim.

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(MethodHandle.java:1237)
	at java.base/java.lang.invoke.MethodHandle.getCPMethodHandleAt(Native Method)
	at java.base/java.lang.invoke.MethodHandle.resolveInvokeDynamic(MethodHandle.java:1070)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor.schedule(ScheduledThreadPoolExecutor.java:556)
	at co.elastic.apm.agent.profiler.SamplingProfiler.run(SamplingProfiler.java:342)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:836)
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(MethodHandles.java:730)
	at java.base/java.lang.invoke.MethodHandles$Lookup.checkClassModuleVisibility(MethodHandles.java:711)
	at java.base/java.lang.invoke.MethodHandles$Lookup.checkClassAccess(MethodHandles.java:487)
	at java.base/java.lang.invoke.MethodHandles$Lookup.checkAccess(MethodHandles.java:392)
	at java.base/java.lang.invoke.MethodHandles$Lookup.checkAccess(MethodHandles.java:341)
	at java.base/java.lang.invoke.MethodHandles$Lookup.findStatic(MethodHandles.java:621)
	at java.base/java.lang.invoke.MethodHandle.sendResolveMethodHandle(MethodHandle.java:1212)
	... 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 -Dcom.sun.management.jmxremote -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: https://github.com/elastic/apm-agent-java/issues/1415

Building with docker image openjdk:10 and running with docker image adoptopenjdk/openjdk10:jdk-10.0.2.13-alpine-slim 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.
Thanks!

1 Like

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