3 Replies Latest reply on Oct 27, 2016 8:47 AM by gaurav6281

    Installing Agent inside another running JVM throwing Agent failed to Initialize error

    gaurav6281

      Hi ,

       

      There is one JVM process running on Machine A having IP address (say) :- 111.111.111.11.    Both byteman jars and the other JVM process are on same host. I..e no Intra Machines interaction.  Everything inside 1 Linux box.

       

      I have to inject Byteman agent dynamically inside this running JVM and once successful then I will run my submit command to load my rules dynamically.

       

      (a) I am trying to install agent dynamically like below:-

       

      bash-4.1$  java -classpath /tmp/gaurav/byteman/byteman.jar:/tmp/gaurav/byteman/byteman-install.jar:/tmp/gaurav/byteman/tools.jar org.jboss.byteman.agent.install.Install -h 111.111.111.11 -p 12345 -Dorg.jboss.byteman.verbose 3411

       

      (12345 is random available port on the box and 3411 is the process ID in which I want to inject my agent and subsequently run my rules)

      Output on Linux prompt:-

       

      byteman jar is /tmp/gaurav/byteman/byteman.jar

      com.sun.tools.attach.AgentInitializationException: Agent JAR loaded but agent failed to initialize

       

      Can anybody please advice why Agent is not getting initialized. (the error do not explains why it has failed)

        • 1. Re: Installing Agent inside another running JVM throwing Agent failed to Initialize error
          gaurav6281

          Just to add , I am using oracle-jdk/1.8.0.40/linux-x64/bin/java    and byteman version is 2.1.2  .

           

          tools.jar is also from oracle-jdk/1.8.0.40/linux-x64/lib  location

          • 2. Re: Installing Agent inside another running JVM throwing Agent failed to Initialize error
            adinn

            Hi Gaurav,

             

            There are several reasons why the agent might fail to initialize. The problem you are seeing here will be happening in the JVM that you are trying to install the agent into (i.e. process 3411 in the above report).

             

            Could you please start that JVM with -Dorg.jboss.byteman.verbose on the command line and then report any Byteman messages or exceptions that are posted to System.out or System.err.

             

            Also, it would be better if you upgraded to the latest Byteman release (3.0.6). This is 100% backwards-compatible with the one you are using and it includes quite a few bug fixes (n.b. I very much doubt this is what is causing whatever problem you are seeing but it is worth using this release just in case it helps with other problems).

             

            regards,

             

             

            Andrew Dinn

            • 3. Re: Installing Agent inside another running JVM throwing Agent failed to Initialize error
              gaurav6281

              Hi Andrew,

               

              I am trying to first test on windows now.

               

              (1) I started one main java class from IntelliJ community edition version 2016.1.2b. JDK 64 bit 8 is being used inside IntelliJ

              (2) Once above main class was started successfully, I fired jps command in windows prompt which showed me process Id as 13544(This Is Intelli J process id as when I try to kill 13544, I got a pop up of exiting IntelliJ..not sure how to get Java process Id running inside Inteli J ?

               

              (3) Then I fired below command form windows command prompt :-

               

              C:\FAST\JDK64\1.8.0.74\jre\bin\java -classpath "C:/Users/gaurav/byteman.jar";"C:/Users/gaurav/byteman-install.jar";"C:/Users/gaurav/tools.jar" org.jboss.byteman.agent.install.Install -h localhost -p 12345 -Dorg.jboss.byteman.verbose 13544

               

              (all byteman jars are 3.0.6 version jars and tools.jar I also from JDK 64 bit 8 )

               

              But I am getting below error:-

               

              com.sun.tools.attach.AttachNotSupportedException: Unable to attach to 32-bit process running under WOW64

               

              When I googled , I found article :- JVM Monitor documentation   which says :-

               

              If you see the additional message "Unable to attach to 32-bit process running under WOW64",     your application is running with 32bit Java while using 64bit Eclipse on Windows.    Either using 64bit Java for your application or using 32bit Eclipse solves the issue

               

              But, My Intelli J is using Java 64 bit 8 , my command prompt command is also making use of jdk 64 bit 8.  Not sure what is the error? Is it that IntelliJ which I am using is 32 bit and community edition do not support 64 bit IntelliJ ??

              or may be I am injecting agent into proess  id of IntelliJ and not of my java program running inside IntelliJ ???

               

              Kindly suggest.