2 Replies Latest reply on Dec 22, 2015 1:41 AM by mahesh.shet

    not able to find issue from bmcheck script output...

    mahesh.shet

      Hi,

       

      I am trying to inject fault in a long running java application.

       

      The rule file (test.btm) contains the following:

      #==============================================================

      # Throwing Exceptions on Calling MyTestAPI

      #==============================================================

      RULE Throw TestException

      CLASS NewAccountCreate

      METHOD TestMethod

      AT ENTRY

      IF TRUE

      DO THROW new com.test.mvs..exception.TestException("This is a test exception");

      ENDRULE

       

      I am calling the bmcheck on test.btm and getting the following output:

      ./bmcheck.sh ../sample/mvsScripts/test.btm

      ERROR : Could not load class NewAccountCreate declared in rule "Throw TestException" loaded from ../sample/mvsScripts/test.btm line 8

      TestScript: 1 total errors

                  0 total warnings

                  0 parse errors

                  0 type errors

                  0 type warnings

       

      Question1: Why bmcheck.sh output says could not load class? As I understand, bmcheck.sh checks for the validity of the rules....and I am not understanding where in the rule there is a problem.

       

      Question2: I have successfully installed the byteman in to a long running java application.I am able to load the rules also. When I check if the rule is compiled successfully, i see compilation error as shown below (modified the part of the error to hide my code):

       

      $ sudo ./bmsubmit.sh

      # File ../sample/mvsScripts/test.btm line 9

      RULE Throw TestException

      CLASS NewAccountCreate

      METHOD TestMethod

      AT ENTRY

      IF TRUE

      DO THROW new com.test.mvs..exception.TestException("This is a test exception");

      ENDRULE

       

       

      Transformed in:

      loader: sun.misc.Launcher$AppClassLoader@c387f44

      trigger method: com.sometest.mvs.resources.NewAccountCreate.TestMethod(java.lang.String,com.sometest.mvs.requests.TestRequest,javax.ws.rs.core.HttpHeaders) javax.ws.rs.core.Response

      failed to compile

      Rule.ensureTypeCheckedCompiled : error type checking rule Throw TestException

      org.jboss.byteman.rule.exception.TypeException: StringLiteral.typeCheck : invalid expected type com.sometest.mvs.data.enums.SomeResponseCode file ../sample/mvsScripts/test.btm line 11

       

      Kindly help. Thanking you in advance.

       

      Regards

      Mahesh

        • 1. Re: not able to find issue from bmcheck script output...
          adinn

          Hi mahesh

           

          I am calling the bmcheck on test.btm and getting the following output:

          ./bmcheck.sh ../sample/mvsScripts/test.btm

          ERROR : Could not load class NewAccountCreate declared in rule "Throw TestException" loaded from ../sample/mvsScripts/test.btm line 8

          TestScript: 1 total errors

                      0 total warnings

                      0 parse errors

                      0 type errors

                      0 type warnings

           

          Question1: Why bmcheck.sh output says could not load class? As I understand, bmcheck.sh checks for the validity of the rules....and I am not understanding where in the rule there is a problem.

           

          You have told bmcheck where to look for your script but you have not told it where to look fo r he class definition nor what package the class lies in. You need to call it like this:

           

            ./bmcheck.sh -cp /path/to/my.jar -p com.sometest.mvs.resources.NewAccountCreate ../sample/mvsScripts/test.btm

           

          The -cp argument points bmcheck at the jar containing class NewAccontCreate.

           

          The -p argument says when looking for a class with name NewAccountCreate try looking in package com.sometest.resources.

           

          Question2: I have successfully installed the byteman in to a long running java application.I am able to load the rules also. When I check if the rule is compiled successfully, i see compilation error as shown below (modified the part of the error to hide my code):

           

          $ sudo ./bmsubmit.sh

          # File ../sample/mvsScripts/test.btm line 9

          RULE Throw TestException

          CLASS NewAccountCreate

          METHOD TestMethod

          AT ENTRY

          IF TRUE

          DO THROW new com.test.mvs..exception.TestException("This is a test exception");

          ENDRULE

          . . .

          trigger method: com.sometest.mvs.resources.NewAccountCreate.TestMethod(java.lang.String,com.sometest.mvs.requests.TestRequest,javax.ws.rs.core.HttpHeaders) javax.ws.rs.core.Response

          failed to compile

          Rule.ensureTypeCheckedCompiled : error type checking rule Throw TestException

          org.jboss.byteman.rule.exception.TypeException: StringLiteral.typeCheck : invalid expected type com.sometest.mvs.data.enums.SomeResponseCode file ../sample/mvsScripts/test.btm line 11

           

          Well, the type check error message says that the problem occurs when checking a StringLiteral which obviously can only mean the argument "This is a test exception" (that's the only string value occurring in your rule). Specifically it is saying that the expected type for this value is com.sometest.mvs.data.enums.SomeResponseCode. So, it looks to me like you have passed in the wrong type of argument in the constructor to TestException. Have a look at the constructor and see what type of argument it expects.

           

          regards,

           

           

          Andrew Dinn

          • 2. Re: not able to find issue from bmcheck script output...
            mahesh.shet

            Hi Andrew,

             

            Thanks a lot for point to the error correctly. You saved my day. Thanks again.

             

            Regards

            Mahesh