# IllegalAccessError: Module access

**URL:** <https://discuss.elastic.co/t/illegalaccesserror-module-access/249452>\
**Category:** APM\
**Tags:** java\
**Created:** [September 22, 2020, 5:59am UTC](https://discuss.elastic.co/t/illegalaccesserror-module-access/249452 "2020-09-22T05:59:00Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![joames](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joames/32/47012_2.png) [@joames](https://discuss.elastic.co/u/joames)\
**Post date:** [September 22, 2020, 5:59am UTC](https://discuss.elastic.co/t/illegalaccesserror-module-access/249452/1 "2020-09-22T05:59:01Z")

</div>

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.

```auto
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

```

---

<div class="post-metadata">

**Author:** ![Sylvain\_Juge](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sylvain_juge/32/55521_2.png) [@Sylvain\_Juge](https://discuss.elastic.co/u/Sylvain_Juge)\
**Post date:** [September 22, 2020, 7:13am UTC](https://discuss.elastic.co/t/illegalaccesserror-module-access/249452/2 "2020-09-22T07:13:36Z")

</div>

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 !

---

<div class="post-metadata">

**Author:** ![joames](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joames/32/47012_2.png) [@joames](https://discuss.elastic.co/u/joames)\
**Post date:** [September 22, 2020, 7:20am UTC](https://discuss.elastic.co/t/illegalaccesserror-module-access/249452/3 "2020-09-22T07:20:04Z")

</div>

```auto
CMD java -Dcom.sun.management.jmxremote -noverify ${JAVA_OPTS} -javaagent:elastic-apm-agent.jar -jar app.jar

```

and `JAVA_OPTS` is an empty string

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [September 23, 2020, 6:27am UTC](https://discuss.elastic.co/t/illegalaccesserror-module-access/249452/4 "2020-09-23T06:27:29Z")

</div>

@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?

---

<div class="post-metadata">

**Author:** ![joames](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joames/32/47012_2.png) [@joames](https://discuss.elastic.co/u/joames)\
**Post date:** [September 23, 2020, 6:46am UTC](https://discuss.elastic.co/t/illegalaccesserror-module-access/249452/5 "2020-09-23T06:46:11Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [September 23, 2020, 6:47am UTC](https://discuss.elastic.co/t/illegalaccesserror-module-access/249452/6 "2020-09-23T06:47:25Z")

</div>

Awesome, this is extremely useful information. Thanks! 🙏

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [September 23, 2020, 6:48am UTC](https://discuss.elastic.co/t/illegalaccesserror-module-access/249452/7 "2020-09-23T06:48:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![joames](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joames/32/47012_2.png) [@joames](https://discuss.elastic.co/u/joames)\
**Post date:** [September 23, 2020, 7:08am UTC](https://discuss.elastic.co/t/illegalaccesserror-module-access/249452/8 "2020-09-23T07:08:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Sylvain\_Juge](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sylvain_juge/32/55521_2.png) [@Sylvain\_Juge](https://discuss.elastic.co/u/Sylvain_Juge)\
**Post date:** [September 23, 2020, 7:33am UTC](https://discuss.elastic.co/t/illegalaccesserror-module-access/249452/9 "2020-09-23T07:33:57Z")

</div>

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](https://github.com/elastic/apm-agent-java/issues/1415)

---

<div class="post-metadata">

**Author:** ![joames](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joames/32/47012_2.png) [@joames](https://discuss.elastic.co/u/joames)\
**Post date:** [September 23, 2020, 7:35am UTC](https://discuss.elastic.co/t/illegalaccesserror-module-access/249452/10 "2020-09-23T07:35:13Z")

</div>

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.

```auto
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

```

---

<div class="post-metadata">

**Author:** ![Sylvain\_Juge](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sylvain_juge/32/55521_2.png) [@Sylvain\_Juge](https://discuss.elastic.co/u/Sylvain_Juge)\
**Post date:** [September 23, 2020, 7:47am UTC](https://discuss.elastic.co/t/illegalaccesserror-module-access/249452/11 "2020-09-23T07:47:45Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [September 23, 2020, 8:18am UTC](https://discuss.elastic.co/t/illegalaccesserror-module-access/249452/12 "2020-09-23T08:18:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 14, 2020, 4:18am UTC](https://discuss.elastic.co/t/illegalaccesserror-module-access/249452/13 "2020-10-14T04:18:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [November 3, 2020, 12:16pm UTC](https://discuss.elastic.co/t/illegalaccesserror-module-access/249452/14 "2020-11-03T12:16:12Z")

</div>

@joames We finally got the chance to tackle this issue. Please test [this snapshot](https://apm-ci.elastic.co/blue/organizations/jenkins/apm-agent-java%2Fapm-agent-java-mbp/detail/PR-1468/2/artifacts) and see if it resolves the issue.  
Thanks!

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [November 11, 2020, 6:29am UTC](https://discuss.elastic.co/t/illegalaccesserror-module-access/249452/15 "2020-11-11T06:29:36Z")

</div>

Version [1.19.0](https://www.elastic.co/guide/en/apm/agent/java/current/release-notes-1.x.html#release-notes-1.19.0) is released with a proposed fix for this issue.
