Topic
  • No replies
d1le
d1le
1 Post

Pinned topic IBM J9 adding retransformable transformers is not supported

‏2019-04-12T09:13:31Z |

Hello!

I have an issue with initializing java agent.

My env:

WebSphere 8.5.5.12

JRE 1.8.0 IBM J9 2.8 Linux amd64-64 Compressed References 20170419_344392 (JIT enabled, AOT enabled)
J9VM - R28_20170419_1004_B344392
JIT - tr.r14.java_20170419_344392
GC - R28_20170419_1004_B344392_CMPRSS
J9CL - 20170419_344392

 

When I tried to use elastic-apm-agent (attaching to running jvm) I found out that on some envs (same as above description) agent succeeded to run and on thrers it failed with message in SystemErr.log:

[4/11/19 14:41:40:355 MSK] 0000006f SystemErr R Failed to start agent

[4/11/19 14:42:13:500 MSK] 0000013e SystemErr R java.lang.reflect.InvocationTargetException

[4/11/19 14:42:13:501 MSK] 0000013e SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

[4/11/19 14:42:13:501 MSK] 0000013e SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)

[4/11/19 14:42:13:501 MSK] 0000013e SystemErr R at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)

[4/11/19 14:42:13:501 MSK] 0000013e SystemErr R at java.lang.reflect.Method.invoke(Method.java:508)

[4/11/19 14:42:13:502 MSK] 0000013e SystemErr R at co.elastic.apm.agent.bci.AgentMain.init(AgentMain.java:78)

[4/11/19 14:42:13:502 MSK] 0000013e SystemErr R at co.elastic.apm.agent.bci.AgentMain.agentmain(AgentMain.java:59)

[4/11/19 14:42:13:502 MSK] 0000013e SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

[4/11/19 14:42:13:502 MSK] 0000013e SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)

[4/11/19 14:42:13:503 MSK] 0000013e SystemErr R at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)

[4/11/19 14:42:13:503 MSK] 0000013e SystemErr R at java.lang.reflect.Method.invoke(Method.java:508)

[4/11/19 14:42:13:503 MSK] 0000013e SystemErr R at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:408)

[4/11/19 14:42:13:503 MSK] 0000013e SystemErr R at sun.instrument.InstrumentationImpl.loadClassAndCallAgentmain(InstrumentationImpl.java:433)

[4/11/19 14:42:13:503 MSK] 0000013e SystemErr R at com.ibm.tools.attach.javaSE.Attachment.loadAgentLibraryImpl(Native Method)

[4/11/19 14:42:13:504 MSK] 0000013e SystemErr R at com.ibm.tools.attach.javaSE.Attachment.loadAgentLibrary(Attachment.java:309)

[4/11/19 14:42:13:504 MSK] 0000013e SystemErr R at com.ibm.tools.attach.javaSE.Attachment.parseLoadAgent(Attachment.java:287)

[4/11/19 14:42:13:504 MSK] 0000013e SystemErr R at com.ibm.tools.attach.javaSE.Attachment.doCommand(Attachment.java:168)

[4/11/19 14:42:13:504 MSK] 0000013e SystemErr R at com.ibm.tools.attach.javaSE.Attachment.run(Attachment.java:128)

[4/11/19 14:42:13:504 MSK] 0000013e SystemErr R Caused by: java.lang.IllegalStateException: Could not install class file transformer

[4/11/19 14:42:13:505 MSK] 0000013e SystemErr R at co.elastic.apm.agent.shaded.bytebuddy.agent.builder.AgentBuilder$Default.installOn(AgentBuilder.java:9215)

[4/11/19 14:42:13:505 MSK] 0000013e SystemErr R at co.elastic.apm.agent.shaded.bytebuddy.agent.builder.AgentBuilder$Default$Delegator.installOn(AgentBuilder.java:11152)

[4/11/19 14:42:13:505 MSK] 0000013e SystemErr R at co.elastic.apm.agent.bci.ElasticApmAgent.initInstrumentation(ElasticApmAgent.java:141)

[4/11/19 14:42:13:506 MSK] 0000013e SystemErr R at co.elastic.apm.agent.bci.ElasticApmAgent.initInstrumentation(ElasticApmAgent.java:94)

[4/11/19 14:42:13:506 MSK] 0000013e SystemErr R at co.elastic.apm.agent.bci.ElasticApmAgent.initialize(ElasticApmAgent.java:90)

[4/11/19 14:42:13:506 MSK] 0000013e SystemErr R ... 17 more

[4/11/19 14:42:13:506 MSK] 0000013e SystemErr R Caused by: java.lang.IllegalStateException: Error invoking java.lang.instrument.Instrumentation#addTransformer

[4/11/19 14:42:13:507 MSK] 0000013e SystemErr R at co.elastic.apm.agent.shaded.bytebuddy.agent.builder.AgentBuilder$Default$Dispatcher$ForJava6CapableVm.addTransformer(AgentBuilder.java:9400)

[4/11/19 14:42:13:507 MSK] 0000013e SystemErr R at co.elastic.apm.agent.shaded.bytebuddy.agent.builder.AgentBuilder$Default.installOn(AgentBuilder.java:9191)

[4/11/19 14:42:13:507 MSK] 0000013e SystemErr R ... 21 more

[4/11/19 14:42:13:507 MSK] 0000013e SystemErr R Caused by: java.lang.UnsupportedOperationException: adding retransformable transformers is not supported in this environment

[4/11/19 14:42:13:509 MSK] 0000013e SystemErr R at sun.instrument.InstrumentationImpl.addTransformer(InstrumentationImpl.java:100)

[4/11/19 14:42:13:510 MSK] 0000013e SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

[4/11/19 14:42:13:510 MSK] 0000013e SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)

[4/11/19 14:42:13:510 MSK] 0000013e SystemErr R at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)

[4/11/19 14:42:13:510 MSK] 0000013e SystemErr R at java.lang.reflect.Method.invoke(Method.java:508)

[4/11/19 14:42:13:510 MSK] 0000013e SystemErr R at co.elastic.apm.agent.shaded.bytebuddy.agent.builder.AgentBuilder$Default$Dispatcher$ForJava6CapableVm.addTransformer(AgentBuilder.java:9396)

[4/11/19 14:42:13:511 MSK] 0000013e SystemErr R ... 22 more

 

Agent has Can-Retransform-Classes: true entry in manifest.

 

The only difference I have spotted between envs is a debug mode.

So when debug mode is on in WebSphere server configuration - everything is ok. On the other hand, when debug mode is off (which is on most of our envs) agent fails.

I build a simple agent that calls isRetransformClassesSupprted on passed instrumentation and try to attach it to jvm. No debug mode - the answer is false, debug mode - true.

 

Tried this simple agent with oracle jre - isRetransformClassesSupprted method always returns true.

 

My question: is there a way to use retransformable agent with J9 jre without debug mode?