4 Replies Latest reply on Nov 29, 2012 4:45 AM by henrik_sr

    Arquillian Byteman extension - Rule ruleMapKey always empty -> no code injected

    henrik_sr

      Hi

       

      I am working on a project where we use Arquillian together with GlassFish 3.

       

      However, we have struggled to use the Arquillian-ByteMan extension and seem to have hit wall wrt. getting our injection code invoked.

       

      When we debug, the context in which the public static execute method on Rule is invoked has an empty  HashMap<String, Rule> ruleKeyMap.

      Hence our injected rule code is never invoked.

      Before reaching the execute method we have verified that the rule is in fact added to the ruleKeyMap and not yet been purged.

       

      Below you will find the very simple test class and also the dependencies used.

       

      Please note that I have to set autoInstallAgent to false and in my running Glassfish3 instance add this to the

      JVM options of the server config: -javaagent:${com.sun.aas.instanceRoot}/lib/byteman-2.1.0.jar=listener:true,port:9999

       

      So to sum up - can anyone maybe explain in which contexts the Rule class is used and why this problem occurs.

       

      Currently we can not defend spending more time on getting this work so another approach will have to be taken.

      If anyone can guide us in the right direction I will however try to get this working since it really seems ideal for our error test scenarios.

       

      Thank you in advance.

       

      Regards Henrik

       

      @RunWith(Arquillian.class)

      public class ByteManGlassfish3Test_IT

      {

       

          @Deployment

          public static Archive<?> deployment()

          {

              return DeploymentHelper.createArchive();

          }

       

          @Test

          @BMRule(

                  name="FaultyInjectionRule",

                  targetClass="com.ejb.egs.ByteManGlassfish3Test_IT.TestClass",

                  targetMethod="testMethod",

                  action="System.out.println(\"Test impl\");"

                  )

       

          public void injectFaultyMethod() throws Exception

          {

              new TestClass().testMethod();

          }

       

          public static class TestClass

          {

              public void testMethod()

              {

                  System.out.println("Real Impl");

                  Assert.fail();

              }

          }

      }

      Added to my pom.xml

        <properties>

            <toolsjar>${java.home}/../Classes/classes.jar</toolsjar>

            <version.byteman>2.1.0</version.byteman>

        </properties>

      <dependency>

                <groupId>org.jboss.arquillian.extension</groupId>

                <artifactId>arquillian-extension-byteman</artifactId>

                <version>1.0.0.Alpha2</version>

                <scope>test</scope>

            </dependency>

            <dependency>

                <groupId>com.sun</groupId>

                <artifactId>tools</artifactId>

                <version>1.6.0</version>

                <scope>system</scope>

                <systemPath>${toolsjar}</systemPath>

            </dependency>

            <dependency>

                <groupId>org.jboss.byteman</groupId>

                <artifactId>byteman</artifactId>

                <version>${version.byteman}</version>

                <scope>provided</scope>

            </dependency>

            <dependency>

                <groupId>org.jboss.byteman</groupId>

                <artifactId>byteman-submit</artifactId>

                <version>${version.byteman}</version>

                <scope>provided</scope>

            </dependency>

            <dependency>

                <groupId>org.jboss.byteman</groupId>

                <artifactId>byteman-install</artifactId>

                <scope>test</scope>

                <version>${version.byteman}</version>

            </dependency>

            <dependency>

                <groupId>org.jboss.byteman</groupId>

                <artifactId>byteman-bmunit</artifactId>

                <scope>test</scope>

                <version>${version.byteman}</version>

            </dependency>

       

      Added to my arquillian.xml in test resources:

      <extension qualifier="byteman">

            <property name="autoInstallAgent">false</property>

            <property name="agentProperties">org.jboss.byteman.verbose=true</property>

            <property name="clientAgentPort">9999</property>

            <property name="containerAgentPort">9999</property>

        </extension>

       

      Added to my running Glassfish 3 instance   

        -javaagent:${com.sun.aas.instanceRoot}/lib/byteman-2.1.0.jar=listener:true,port:9999

          -Dorg.jboss.byteman.verbose=true

        • 1. Re: Arquillian Byteman extension - Rule ruleMapKey always empty -> no code injected
          aslak

          This setup worked for me

           

          Setup a GlassFish 3.2.1 server with this javaagent options: (mind the local path refs.. )

          -javaagent:/home/aslak/.m2/repository/org/jboss/byteman/byteman/2.0.1/byteman-2.0.1.jar=boot:/home/aslak/.m2/repository/org/jboss/byteman/byteman/2.0.1/byteman-2.0.1.jar,listener:true,port:8888,prop:org.jboss.byteman.verbose=true
          

           

          Using this configuration. setting autoInstall false for both client and container:

          <?xml version="1.0" encoding="UTF-8"?>
          <arquillian xmlns="http://jboss.org/schema/arquillian"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
          
          
              <extension qualifier="byteman">
                  <property name="autoInstallClientAgent">false</property>
                  <property name="autoInstallContainerAgent">false</property>
                  <property name="clientAgentPort">9999</property>
                  <property name="containerAgentPort">8888</property>
              </extension>
          </arquillian>
          

           

          containerAgentPort 8888 should match the port:8888 in -javaagent

           

           

          @RunWith(Arquillian.class)
          public class ByteManGlassfish3Test_IT
          {
              @Deployment
              public static Archive<?> deployment()
              {
                        return ShrinkWrap.create(WebArchive.class)
                                            .addClass(TestClass.class);
              }
          
          
              @Test
              @BMRule(
                      name="FaultyInjectionRule",
                      targetClass="TestClass",
                      targetMethod="testMethod",
                      action = "throw new java.lang.RuntimeException();"
              )
              public void injectFaultyMethod() throws Exception
              {
                        new TestClass().testMethod();
              }
          }
          

           

          Moved the TestClass out of the ByteManGlassfish3Test_IT as it didn't seem to trigger on inner classes. Might just be the targetClass expression that need some tweaking.

          Replaced action with a throw Eception to see a more brutal response. You need to study the Byteman rules to see how they work and where in the code they are injected etc. an Action is not a full replacement of the whole method body. http://downloads.jboss.org/byteman/2.1.0/ProgrammersGuideSinglePage.html

           

          The project used the following pom.xml

           

           

          <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
              <modelVersion>4.0.0</modelVersion>
              <groupId>org.arquillian.glassfish.byteman</groupId>
              <artifactId>glassfish-byteman</artifactId>
              <version>0.0.1-SNAPSHOT</version>
              <name>Test GlassFish with Byteman Extension</name>
          
          
              <properties>
                  <version.arquillian_core>1.0.3.Final</version.arquillian_core>
                  <version.arquillian_glassfish>1.0.0.CR3</version.arquillian_glassfish>
                  <version.arquillian_byteman>1.0.0.Alpha2</version.arquillian_byteman>
                  <version.byteman>2.1.0</version.byteman>
                  <version.junit>4.8.1</version.junit>
              </properties>
              
              <dependencyManagement>
                  <dependencies>
                      <dependency>
                          <groupId>org.jboss.arquillian</groupId>
                          <artifactId>arquillian-bom</artifactId>
                          <version>${version.arquillian_core}</version>
                          <type>pom</type>
                          <scope>import</scope>
                      </dependency>
                  </dependencies>
              </dependencyManagement>
              
              <dependencies>
                  <dependency>
                      <groupId>org.jboss.arquillian.junit</groupId>
                      <artifactId>arquillian-junit-container</artifactId>
                      <scope>test</scope>
                  </dependency>
                  <dependency>
                      <groupId>org.jboss.arquillian.extension</groupId>
                      <artifactId>arquillian-extension-byteman</artifactId>
                      <version>${version.arquillian_byteman}</version>
                      <scope>test</scope>
                  </dependency>
                  <dependency>
                      <groupId>org.jboss.byteman</groupId>
                      <artifactId>byteman-submit</artifactId>
                      <version>${version.byteman}</version>
                      <scope>provided</scope>
                  </dependency>
                  <dependency>
                      <groupId>junit</groupId>
                      <artifactId>junit</artifactId>
                      <scope>test</scope>
                      <version>${version.junit}</version>
                  </dependency>
              </dependencies>
              
              <profiles>
                  <profile>
                      <id>remote</id>
                      <activation>
                          <activeByDefault>true</activeByDefault>
                      </activation>
                      <dependencies>
                          <dependency>
                              <groupId>org.jboss.arquillian.container</groupId>
                              <artifactId>arquillian-glassfish-remote-3.1</artifactId>
                              <version>${version.arquillian_glassfish}</version>
                              <scope>test</scope>
                          </dependency>
                      </dependencies>
                  </profile>
              </profiles>
          </project>
          
          
          • 2. Re: Arquillian Byteman extension - Rule ruleMapKey always empty -> no code injected
            henrik_sr

            Hi Aslak

            I now have Byteman injecting code in my Glassfish testclass thanks to your help - so thank you!

            The addition of the <property name="autoInstallClientAgent">false</property> in the arquillian.xml and the boot:<path to byteman.jar> where the two important changes you made.

             

            However, I still have one question - and this is not preventing us from using the byteman extension but is more about me understanding how Byteman maintains it's rules.

            I have also pointed the attention of Andrew Dinn to this since it may be more related to Byteman than to the way in which the Arquillian-byteman extension uses Byteman.

             

            The logs below is the result of running the test multiple times from eclipse against my local Glassfish server and to me it indicates that the FaultyInjectionRule is accumulating.

            Each time I run the test, the rule is added to the ruleKeyMap in Rule ( as seen in http://grepcode.com/file/repository.jboss.org/nexus/content/repositories/releases/org.jboss.byteman/byteman/2.0.1/org/jboss/byteman/rule/Rule.java#Rule) but with a new key.

            And each time I run the test, Byteman seems to transform the TestClass for each Rule loaded during the lifetime of the instantiated container.

            However, Byteman only executes the latest rule during test so there is no problem per say, except that you could argue that the rule should not be applied so many times.

            This seems to be due the installScript method in Retransformer line 114 (http://grepcode.com/file/repository.jboss.org/nexus/content/repositories/releases/org.jboss.byteman/byteman/2.0.1/org/jboss/byteman/agent/Retransformer.java?av=f)

            where it get "too many"  TestClasses that is going to be retransformed.

            What is you take on this ?

             

            [#|2012-11-29T09:44:27.778+0400|INFO|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=89;_ThreadName=Thread-3;|WEB0671: Loading application [8a21b4cc-7846-4f55-aeb5-6e0b5c6dfe46] at [/8a21b4cc-7846-4f55-aeb5-6e0b5c6dfe46]|#]

             

            [#|2012-11-29T09:44:27.836+0400|INFO|glassfish3.1.2|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=89;_ThreadName=Thread-3;|8a21b4cc-7846-4f55-aeb5-6e0b5c6dfe46 was successfully deployed in 11,890 milliseconds.|#]

             

            [#|2012-11-29T09:44:28.658+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|TransformListener() : handling connection on port 8888|#]

             

            [#|2012-11-29T09:44:28.745+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|retransforming com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:28.745+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|retransforming com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:28.749+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|retransforming com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:28.750+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|retransforming com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:28.750+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|retransforming com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:28.750+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|retransforming com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:28.750+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|retransforming com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:28.759+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|org.jboss.byteman.agent.Transformer : possible trigger for rule FaultyInjectionRule in class com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:28.760+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|RuleTriggerMethodAdapter.injectTriggerPoint : inserting trigger into com.ejb.egs.TestClass.testMethod() void for rule FaultyInjectionRule|#]

             

            [#|2012-11-29T09:44:28.760+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|org.jboss.byteman.agent.Transformer : inserted trigger for FaultyInjectionRule in class com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:28.780+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|org.jboss.byteman.agent.Transformer : possible trigger for rule FaultyInjectionRule in class com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:28.781+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|RuleTriggerMethodAdapter.injectTriggerPoint : inserting trigger into com.ejb.egs.TestClass.testMethod() void for rule FaultyInjectionRule|#]

             

            [#|2012-11-29T09:44:28.781+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|org.jboss.byteman.agent.Transformer : inserted trigger for FaultyInjectionRule in class com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:28.782+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|org.jboss.byteman.agent.Transformer : possible trigger for rule FaultyInjectionRule in class com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:28.782+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|RuleTriggerMethodAdapter.injectTriggerPoint : inserting trigger into com.ejb.egs.TestClass.testMethod() void for rule FaultyInjectionRule|#]

             

            [#|2012-11-29T09:44:28.783+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|org.jboss.byteman.agent.Transformer : inserted trigger for FaultyInjectionRule in class com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:28.797+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|org.jboss.byteman.agent.Transformer : possible trigger for rule FaultyInjectionRule in class com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:28.797+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|RuleTriggerMethodAdapter.injectTriggerPoint : inserting trigger into com.ejb.egs.TestClass.testMethod() void for rule FaultyInjectionRule|#]

             

            [#|2012-11-29T09:44:28.798+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|org.jboss.byteman.agent.Transformer : inserted trigger for FaultyInjectionRule in class com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:28.798+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|org.jboss.byteman.agent.Transformer : possible trigger for rule FaultyInjectionRule in class com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:28.799+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|RuleTriggerMethodAdapter.injectTriggerPoint : inserting trigger into com.ejb.egs.TestClass.testMethod() void for rule FaultyInjectionRule|#]

             

            [#|2012-11-29T09:44:28.799+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|org.jboss.byteman.agent.Transformer : inserted trigger for FaultyInjectionRule in class com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:28.800+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|org.jboss.byteman.agent.Transformer : possible trigger for rule FaultyInjectionRule in class com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:28.800+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|RuleTriggerMethodAdapter.injectTriggerPoint : inserting trigger into com.ejb.egs.TestClass.testMethod() void for rule FaultyInjectionRule|#]

             

            [#|2012-11-29T09:44:28.801+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|org.jboss.byteman.agent.Transformer : inserted trigger for FaultyInjectionRule in class com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:28.802+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|org.jboss.byteman.agent.Transformer : possible trigger for rule FaultyInjectionRule in class com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:28.802+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|RuleTriggerMethodAdapter.injectTriggerPoint : inserting trigger into com.ejb.egs.TestClass.testMethod() void for rule FaultyInjectionRule|#]

             

            [#|2012-11-29T09:44:28.803+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|org.jboss.byteman.agent.Transformer : inserted trigger for FaultyInjectionRule in class com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:29.859+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=41;_ThreadName=Thread-3;|Rule.execute called for FaultyInjectionRule_26|#]

             

            [#|2012-11-29T09:44:29.863+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=41;_ThreadName=Thread-3;|HelperManager.install for helper class org.jboss.byteman.rule.helper.Helper|#]

             

            [#|2012-11-29T09:44:29.864+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=41;_ThreadName=Thread-3;|calling activated() for helper class org.jboss.byteman.rule.helper.Helper|#]

             

            [#|2012-11-29T09:44:29.864+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=41;_ThreadName=Thread-3;|Default helper activated|#]

             

            [#|2012-11-29T09:44:29.864+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=41;_ThreadName=Thread-3;|calling installed(FaultyInjectionRule) for helper classorg.jboss.byteman.rule.helper.Helper|#]

             

            [#|2012-11-29T09:44:29.865+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=41;_ThreadName=Thread-3;|Installed rule using default helper : FaultyInjectionRule|#]

             

            [#|2012-11-29T09:44:29.865+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=41;_ThreadName=Thread-3;|FaultyInjectionRule execute|#]

             

            [#|2012-11-29T09:44:29.865+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=41;_ThreadName=Thread-3;|Test impl|#]

             

            [#|2012-11-29T09:44:29.866+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=41;_ThreadName=Thread-3;|caught ReturnException|#]

             

            [#|2012-11-29T09:44:29.883+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|TransformListener() : handling connection on port 8888|#]

             

            [#|2012-11-29T09:44:29.922+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|retransforming com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:29.923+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|retransforming com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:29.923+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|retransforming com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:29.923+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|retransforming com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:29.923+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|retransforming com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:29.923+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|retransforming com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:29.923+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|retransforming com.ejb.egs.TestClass|#]

             

            [#|2012-11-29T09:44:30.998+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|HelperManager.uninstall for helper class org.jboss.byteman.rule.helper.Helper|#]

             

            [#|2012-11-29T09:44:31.038+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|calling uninstalled(FaultyInjectionRule) for helper class org.jboss.byteman.rule.helper.Helper|#]

             

            [#|2012-11-29T09:44:31.038+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|Uninstalled rule using default helper : FaultyInjectionRule|#]

             

            [#|2012-11-29T09:44:31.039+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|calling deactivated() for helper classorg.jboss.byteman.rule.helper.Helper|#]

             

            [#|2012-11-29T09:44:31.039+0400|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=5;_ThreadName=Thread-3;|Default helper deactivated|#]

             

            Regards Henrik

            • 3. Re: Arquillian Byteman extension - Rule ruleMapKey always empty -> no code injected
              adinn

              Hi Henrik,

               

              The key part of Aslak's fix is indeed to install the agent on the java command line with "boot:/path/to/m2repo/byteman.jar " in the agent options and disable loading of the agent by the rquilian Byteman plugin. This works because it means that the agent code is available via the bootstrap loader from the very start of applicaton execution i.e. before anything in the test can possibly reference it. That will avoid theproblem I outlined on the Byteman forum where the application loads Rule from the system classpath before the  plugin has auto-laoded the agent and placed the jar in the bootstrap path.

               

              The multiple injection you are seeing looks to me like a problem I have seen before with classloading -- or rather class unloading. When Byteman loads the rule which applies to TestClass the agent's Retransformer searches the loaded class base for any class with that name and schedules it to be retransformed. When the rule is unloaded it untransforms the class. It only ever schedules a given class for transformation once by a given rule. It is also guaranteed to untransform the class and retransform it if the rule is unloaded and reloaded, or even if it is just reloaded without a prior unload. So, these messages definitely do not mean that the same class ahs been injected into twice.

               

              So, if you see several messages saying that TestClass has been transformed then this will be because there is more than one class with that name. This may be because you have run the test multiple times and and hence Arquilina has loaded the class in one class laoder and then reloaded it in another classloader. It may even be that when Arquilian runs your test it is submiting multiple deployments to the server each of which has its own version of testClass in its own classloader. You might wonder why Arquilian is not  releasing all references to previous deployments and hence why old versions of TestClass still appear in the class base. That's because of two reasons: dropping and unloadlng deployments does not ensure that all references to the class disappear; even after all references are dropped a class will not disappear until enough dead state has been garbage collected to detect that it is no longer referenced. So, occaisonally classes hang around in the runtime after their sell-by date and Byteman finds them when it is loading a rule intended for the real (active) version of the class with the same name. Don't worry about it as the dead versions will never get executed.

              1 of 1 people found this helpful
              • 4. Re: Arquillian Byteman extension - Rule ruleMapKey always empty -> no code injected
                henrik_sr

                Hi Andrew

                 

                Again thanks.

                Your answer is very clear and detailed. I now understand why I am getting all these repeated transformations and why the agent is only started at container startup and not by the arquillian extension.

                 

                Regards Henrik