6 Replies Latest reply on Oct 14, 2015 10:45 AM by Andrew Dinn

    Loading external helper

    Ondřej Kalman Newbie

      Hi, i'm trying to use own helper class with latest EAP started with arquillian. but when rule is triggered, I always get

      org.jboss.byteman.rule.exception.TypeException: Rule.typecheck : unknown helper class org.jboss.qa.hornetq.BytemanCustomHelper for rule myRule

       

      I'm starting server with these java opts:

      -Xms64m -Xmx788m -XX:MaxPermSize=256m

        -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000

        -Dorg.jboss.byteman.transform.all

        -Dsun.rmi.dgc.server.gcInterval=3600000

        -javaagent:${BYTEMAN_JAR}=prop:org.jboss.byteman.verbose=true,address:${MYTESTIP_3},port:9091,boot:/tmp/external.jar

        -Djboss.modules.system.pkgs=org.jboss.byteman,org.jboss.qa.hornetq -Xbootclasspath/a:${BYTEMAN_JAR}:${BYTEMAN_SUBMIT_JAR}:/tmp/external.jar

       

      in  /tmp/external.jar is class org.jboss.qa.hornetq.BytemanCustomHelper. Whats wrong with my procedure?

       

      Rule:

      RULE myRule

      CLASS org.jboss.qa.hornetq.apps.servlets.ServletProducerTransAck

      METHOD sendMessage

      AT INVOKE MessageProducer.send()

      HELPER org.jboss.qa.hornetq.BytemanCustomHelper

      IF TRUE

      DO System.out.println("Byteman will invoke network failure");executeCmd("echo ahoj");

      ENDRULE

        • 1. Re: Loading external helper
          Andrew Dinn Master

          Hi Ondřej,

           

          I think the problem is this

           

          -Djboss.modules.system.pkgs=org.jboss.byteman,org.jboss.qa.hornetq
          

           

          It should be

           

          -Dorg.jboss.modules.system.pkgs=org.jboss.byteman,org.jboss.qa.hornetq
          

           

          Try the latter and let me know if it works.

           

          regards,

           

           

          Andrew Dinn

          • 2. Re: Loading external helper
            Ondřej Kalman Newbie

            Unfortunately not working for me, it's still the same.

            • 3. Re: Loading external helper
              Andrew Dinn Master

              Hi Ondřej,

               

              Oops, sorry, you were right first time the property setting you need is indeed

               

              -Djboss.modules.system.pkgs=org.jboss.byteman,org.jboss.qa.hornetq
              

               

              Could you try relocating your helper code into some other package -- say org.jboss.byteman.qa.hornetq or org.jboss.test.qa.hornetq and see if the module loader can find it when using that package name (n.b. ig f you use the first name you will nto have to reset the jboss modules property). I am suspicious that the moduledefinition is causing the loader to look for the helper class locally.

               

              Also, I just noticed that you added this on your java command line

               

              -Xbootclasspath/a:${BYTEMAN_JAR}:${BYTEMAN_SUBMIT_JAR}:/tmp/external.jar
              

               

              I don't really understand why you are doing this.

               

              Normally, you add the byteman jar to the bootstrap classpath by passing option boot:${BYTEMAN_JAR} to -javaagent.

               

              When using the BMUnit package the bmsubmit jar does not need to be in the bootstrap. Have the Arquilian team recommended adding this jar to the bootstrap? Is that because it is being used from Arquilian code located in the bootstrap path? If not then you probably just need it in your classpath.

               

              You don't need to add /tmp/external.jar to the bootstrap using -Xbootclasspath when you are also adding it to the bootstrap using the javaagent option boot:/tmp/external.jar. That just adds it twice.

              • 4. Re: Loading external helper
                Ondřej Kalman Newbie

                Ok, so i tried to rename package to org.jboss.byteman.qa.hornetq and it works for me. This should be documented somewhere, so many hours of effort, to make this helper work....

                 

                Thanks a lot for your advice.

                • 5. Re: Loading external helper
                  Ondra Chaloupka Expert

                  okalman: if you use byteman in combination with Arquillian it would be good to check what version of controller or in fact exactly the dependency org.wildfly.core:wildfly-launcher you use. This trouble could be caused by https://issues.jboss.org/browse/WFLY-4552. In older version all the information from -Djboss.modules.system.pkgs was removed and forcibly replaced by org.jboss.byteman. As the package org.jboss.byteman.qa.hornetq works for you it could be this issue as issue of WildFly and not the Byteman itself.

                  • 6. Re: Loading external helper
                    Andrew Dinn Master

                    Ondřej Kalman wrote:

                     

                    Ok, so i tried to rename package to org.jboss.byteman.qa.hornetq and it works for me. This should be documented somewhere, so many hours of effort, to make this helper work....

                     

                    Thanks a lot for your advice.

                     

                    Well, that's not quite everything all over as far as I am concerned.

                     

                    When you set jboss.modules.system.pkgs to the value "org.jboss.byteman,org.jboss.qa.hornetq" it didn't make the Helper package visible globally. that really ought to work. It's doesn't make sense to require that every Helper class live in a subpackage of org.jboss.byteman.

                     

                    I don't know if this is failing because 1) JBoss Modules is not recognising the setting, 2 JBoss Modules is ignoring it because it thinks org.jboss.qa.hornetq classes shold be loaded from some other module loader or 3) Arquilian is fiddling the module loaders to redirect lookups for org.jboss.byteman classes but not for other classes. I'll see if I can find out what is happening.

                     

                    Anyway, i am glad you are ale ot get on with things at least.

                     

                    regards,

                     

                     

                    Andrew Dinn