1 Reply Latest reply on Jul 17, 2017 4:45 AM by Andrew Dinn

    Rule.typecheck : unknown helper class

    Pablo Crespo Newbie

      I'm trying to inspect a code which is within an existing jar. I have created a custom helper to trace the content for a parameter. Although the app is throwing an exception when reaching that point

       

      org.jboss.byteman.agent.Transformer : unexpected error parsing rule trace watermark selection

      org.jboss.byteman.rule.exception.TypeException: Rule.typecheck : unknown helper class org.jboss.byteman.SelectorIterator for rule trace watermark selection

      org.jboss.byteman.rule.exception.TypeException: Rule.typecheck : unknown helper class org.jboss.byteman.SelectorIterator for rule trace watermark selection

        at org.jboss.byteman.rule.Rule.<init>(Rule.java:233)

        at org.jboss.byteman.rule.Rule.create(Rule.java:356)

        at org.jboss.byteman.agent.TransformContext.parseRule(TransformContext.java:173)

        at org.jboss.byteman.agent.TransformContext.transform(TransformContext.java:83)

        at org.jboss.byteman.agent.Transformer.transform(Transformer.java:748)

        at org.jboss.byteman.agent.Transformer.tryTransform(Transformer.java:815)

        at org.jboss.byteman.agent.Transformer.tryTransform(Transformer.java:787)

        at org.jboss.byteman.agent.Transformer.transform(Transformer.java:260)

        at sun.instrument.TransformerManager.transform(TransformerManager.java:188)

        at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428)

       

      I'm running the app from within eclipse, the arguments defined as part of my conf option is below,

       

      -XX:PermSize=128M -XX:MaxPermSize=256M -Dorg.jboss.byteman.verbose -Dorg.jboss.byteman.transform.all -Djboss.modules.system.pkgs=org.jboss.byteman,org.jboss.byteman -javaagent:/Users/pablo.crespo/byteman-download-3.0.10/lib/byteman.jar=script:/Users/pablo.crespo/AnypointStudio/wks/watermark-troubleshooting/src/main/resources/byteman-scripts/watermark-inspector.btm

       

      The custom helper code is part of my project, it looks like this problem is related to a class loader issue. Although it is not clear to me why this is not properly handled by eclipse itself.

        • 1. Re: Rule.typecheck : unknown helper class
          Andrew Dinn Master

          Hi Pablo,

           

          It might be useful to know what version of Java and Byteman you are using.

           

          Pablo Crespo wrote:

           

          I'm trying to inspect a code which is within an existing jar. I have created a custom helper to trace the content for a parameter. Although the app is throwing an exception when reaching that point

           

          org.jboss.byteman.agent.Transformer : unexpected error parsing rule trace watermark selection

          org.jboss.byteman.rule.exception.TypeException: Rule.typecheck : unknown helper class org.jboss.byteman.SelectorIterator for rule trace watermark selection

          org.jboss.byteman.rule.exception.TypeException: Rule.typecheck : unknown helper class org.jboss.byteman.SelectorIterator for rule trace watermark selection

          at org.jboss.byteman.rule.Rule.<init>(Rule.java:233)

          . . .

           

          That means that the classloader for the byteman agent is unable to resolve "org.jboss.byteman.SelectorIterator" to a class. Is there a reason why you have added this class to package "org.jboss.byteman"? It is not a problem to do that -- I am just curious as to why you chose to do so.

           

          Pablo Crespo wrote:

           

          I'm running the app from within eclipse, the arguments defined as part of my conf option is below,

           

          -XX:PermSize=128M -XX:MaxPermSize=256M -Dorg.jboss.byteman.verbose -Dorg.jboss.byteman.transform.all -Djboss.modules.system.pkgs=org.jboss.byteman,org.jboss.byteman -javaagent:/Users/pablo.crespo/byteman-download-3.0.10/lib/byteman.jar=script:/Users/pablo.crespo/AnypointStudio/wks/watermark-troubleshooting/src/main/resources/byteman-scripts/watermark-inspector.btm

           

          This should mean that the agent will be loaded by the system classloader. So along with the above error that would mean that class SelectorIterator cannot be in the system classpath (nor in the bootstrap classpath).

           

          Pablo Crespo wrote:

           

           

          The custom helper code is part of my project, it looks like this problem is related to a class loader issue. Although it is not clear to me why this is not properly handled by eclipse itself.

           

          It is definitely a classloader issue in the sense that the exception is thrown when the Byteman code tries and fails to load your helper class. What sort fo classloader issue it is really depends upon what eclipse is doing and, in turn, on how you have organized your code base.

           

          What makes you think that eclipse has added your helper class to the system classpath? Are you sure it has been compiled to bytecode? If you are sure file SelectorIterator.class exists then is it in a location which is in the expected classpath? It might be worth doing some checks to test is going on.

           

          1) You could try modifying the main routine of your Java program to print the value of the system classpath and check that it points to the expected location.

           

          2) Alternatively, you could ensure the class is in the system classpath by explicitly adding it. Insert the helper in a jar file (let's assume it is  /Users/pablo.crespo/helper.jar) and then add the jar to the system classpath via the -javaagent using the sys: option provided by Byteman i.e.change the -javaagent option to

           

          -Djboss.modules.system.pkgs=org.jboss.byteman,org.jboss.byteman  -javaagent:/Users/pablo.crespo/byteman-download-3.0.10/lib/byteman.jar=sys:/Users/pablo.crespo/helper.jar,script:/Users/pablo.crespyteman-scripts/watermark-inspector.btm
          

           

          If the file is found after making this change then that indicates that eclipse is not adding it to the classpath.

           

          Let me know what you find. If SelectorIterator.class really is in the classpath then I will try to advise you how to obtain more information about why Byteman cannot load it.

           

          regards,

           

           

          Andrew Dinn