Kamon icon indicating copy to clipboard operation
Kamon copied to clipboard

kamon-akka: java.lang.reflect.InaccessibleObjectException when using java 17

Open Voltir opened this issue 4 years ago • 4 comments

kamon-akka instrumentation breaks at runtime when using java 17:

[info] -javaagent:/home/voltaire/.cache/coursier/v1/https/repo1.maven.org/maven2/io/kamon/kanela-agent/1.0.13/kanela-agent-1.0.13.jar
[error] Exception in thread "main" java.lang.ExceptionInInitializerError
[error]         at kamon.instrumentation.akka.instrumentations.akka_26.InstrumentNewExecutorServiceOnAkka26$.around(DispatcherInstrumentation.scala:118)
[error]         at akka.dispatch.ForkJoinExecutorConfigurator$ForkJoinExecutorServiceFactory.createExecutorService(ForkJoinExecutorConfigurator.scala)
[error]         at akka.dispatch.Dispatcher$LazyExecutorServiceDelegate.executor$lzycompute(Dispatcher.scala:44)
[error]         at akka.dispatch.Dispatcher$LazyExecutorServiceDelegate.executor(Dispatcher.scala:44)
...
[error]         at scala.App.main(App.scala:80)
[error]         at scala.App.main$(App.scala:78)
[error] Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.concurrent.ExecutorService java.util.concurrent.Executors$DelegatedExecutorService.e accessible: module java.base does not "opens java.util.concurrent" to unnamed module @4f063c0a
[error]         at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
[error]         at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
[error]         at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
[error]         at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
[error]         at kamon.instrumentation.executor.ExecutorInstrumentation$.<init>(ExecutorInstrumentation.scala:260)
[error]         at kamon.instrumentation.executor.ExecutorInstrumentation$.<clinit>(ExecutorInstrumentation.scala)
[error]         ... 34 more

Voltir avatar Oct 12 '21 22:10 Voltir

@dpsoft Any thoughts? This kind of wizardry is usually your specialy 🧙‍♂️

SimunKaracic avatar Oct 20 '21 15:10 SimunKaracic

Hi, you can try with --add-opens java.base/java.util.concurrent=ALL-UNNAMED as JVM param

dpsoft avatar Oct 20 '21 19:10 dpsoft

with adding --add-opens java.base/java.util.concurrent=ALL-UNNAMED to JavaOpts everything was work correct

yarosman avatar Nov 10 '21 11:11 yarosman

Are there plans to get rid of this workaround / be future compatible?

DieBauer avatar Feb 04 '22 16:02 DieBauer