0 Replies Latest reply on May 3, 2015 4:01 PM by rahulk7858

    BCEL, Java assist :-Getting “java.lang.NoClassDefFoundError” on running with javaagent


      I am trying to instrument a jar file (main.jar) with javaagent.jar using BCEL. basically where ever I find any aload in bytecode, I m trying to insert a function call to a static function called Fun() in class "someclass" using

      // this code is in BCEL same can be written using javaassist 
      if (opcode instanceof aload) { iFactory.createInvoke("someclass", "fun", Type.VOID, new Type[]{}, Constants.INVOKESTATIC); 

      my "someclass" class reside in javaagent.jar

      on executing

      java  -javaagent:javaagent.jar -jar main.jar


      java  -javaagent:javaagent.jar -jar main.jar javaagent.jar

      or (I created a separate jar for my "someclass" called someclasscontained.jar)

      java   -javaagent:javaagent.jar -cp "someclasscontained.jar;main.jar "

      I am getting

      Exception in thread "main" java.lang.NoClassDefFoundError: someclass

      error. i tried with -bootclasspath/p option but still not working. does anyone has any clue?

      (1) all jar resides in same folder 2) used fully qualified class name 3) checked silly mistakes