Problems transforming an EJB
simonboggild Dec 9, 2012 3:16 AMHi,
I've been testing Byteman (both version 2.1.0 and 2.1.2) lately in a JEE setup on Glassfish 3.1.2 together with Arquillian 1.0.3.Final and Shrinkwrap 1.1.1-alpha.
Initially I created a simple test class (POJO) and instrumented it with Byteman using a @BMRule in my Arquillian test class. It worked as expected: The action parameter declared in the @BMRule annotation was executed.
However, when I tried to do the same thing on an EJB, I could see in the log that an error occured when Byteman tried to transform the EJB class. Instead of the EJB throwing a RuntimeException as declared in the @BMRule annotation (see below), the EJB just followed its normal flow, indicating that it was not instrumented/transformed at all.
I used the following BMRule annotation:
@Test
@BMRule(
name="MyInjectionRule",
targetClass="com.test.MySessionBean",
targetMethod="testMe",
action="throw new java.lang.RuntimeException();"
)
and saw this output from the server log:
INFO: TransformListener() : handling connection on port 8888
INFO: retransforming com.test.MySessionBean
INFO: retransforming com.test.MySessionBean
INFO: org.jboss.byteman.agent.Transformer : possible trigger for rule MyInjectionRule in class com.test.MySessionBean
INFO: RuleTriggerMethodAdapter.injectTriggerPoint : inserting trigger into com.test.MySessionBean.testMe(java.lang.String) java.lang.String for rule MyInjectionRule
INFO: org.jboss.byteman.agent.Transformer : inserted trigger for MyInjectionRule in class com.test.MySessionBean
INFO: Retransformer : VerifyError during retransformation : some rules may not have been correctly injected or uninjected!
SEVERE: java.lang.VerifyError
at sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
at sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:124)
at org.jboss.byteman.agent.Retransformer.installScript(Retransformer.java:136)
at org.jboss.byteman.agent.TransformListener.handleScripts(TransformListener.java:337)
at org.jboss.byteman.agent.TransformListener.loadScripts(TransformListener.java:260)
at org.jboss.byteman.agent.TransformListener.handleConnection(TransformListener.java:213)
at org.jboss.byteman.agent.TransformListener.run(TransformListener.java:146)
INFO: TransformListener() : handling connection on port 8888
INFO: retransforming com.test.MySessionBean
INFO: retransforming com.test.MySessionBean
With regards to the whole Glassfish/Arquillian/Byteman setup, I followed the instructions from this post, found on the Arquillian forum: https://community.jboss.org/thread/213901?tstart=0
How will I go about debugging what's causing the abovementioned error? As stated in the beginning of this post, Byteman seems to be doing its job on my simple POJO, so what could be the cause of it not being able to transform my EJB?
Another observation is, that if I try to run my working POJO sample after having run the non working EJB sample, the POJO transformation fails with the same error as the EJB. Only after restarting the Glassfish server will the POJO sample start working again (as long as I don't run the EJB sample).
Any help, hints much appreciated.
Kind regards,
Simon