4 Replies Latest reply on Mar 8, 2016 3:53 AM by Andrew Dinn

    Byteman preventing Wildfly 8.1.0 from starting?

    Taylor Marks Newbie

      When my wildfly 8.1.0 server starts up, it should create an instance of a class.

       

      I'm not sure whether that's happening or not, and I'm unable to change the source code, so I figured I would use Byteman to accomplish this.

       

      I wrote this rule file for Byteman, stored at C:\app\ECLSManagedConnectionFactory.btm:

       

       

          RULE trace ECLSManagedConnectionFactory init entry

          CLASS com.empolis.ecls.server.j2ee.jca.impl.ECLSManagedConnectionFactory

          METHOD <init>

          AT ENTRY

          IF true

          DO traceOpen("ECLSManagedConnectionFactory", "/app/ECLSManagedConnectionFactory.log");

             traceln("entering <init>");

             traceClose("ECLSManagedConnectionFactory");

          ENDRULE

       

       

      I downloaded Byteman and unzipped it to C:\byteman-3.0.3.

       

      I modified my java_opts and have wildfly echo the value during startup:

       

       

          -Xms64m -Xmx512m -XX:MaxPermSize=256m

          -Dorg.jboss.byteman.transform.all

          -javaagent:C:/byteman-3.0.3/lib/byteman.jar=script:C:/app/ECLSManagedConnectionFactory.btm,boot:C:/byteman-3.0.3/lib/byteman.jar:listener:true

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

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

          -Djava.net.preferIPv4Stack=true

          -Dorg.jboss.resolver.warning=true

          -Djboss.modules.system.pkgs=org.jboss.byteman

          -Djboss.server.default.config=cls.xml

       

       

      My server successfully starts up if lines 2 and 3 of my java_opts above aren't present, but the moment I add those in, the server simply doesn't start. Nothing to indicate what's happening goes to stdout or stderr. I get a message saying to check server.log for more info, but that file doesn't exist.

       

      What am I doing wrong? I've tried every combination of slash directions for the paths (on Windows 10 if that's important).

       

      (Also, does anyone here use Stack Overflow? I find the lack of a tag for byteman over there to be very odd... it would lead me to think that byteman is a very immature, niche product that nobody uses. If you want to pick up some rep and put an answer where it'll actually be found, post it on this same question over there: http://stackoverflow.com/questions/35849538/byteman-preventing-wildfly-8-1-0-from-starting .)

        • 1. Re: Byteman preventing Wildfly 8.1.0 from starting?
          Andrew Dinn Master

          Hi Taylor,

          Taylor Marks wrote:

            . . .

          I modified my java_opts and have wildfly echo the value during startup:

           

              -Xms64m -Xmx512m -XX:MaxPermSize=256m

              -Dorg.jboss.byteman.transform.all

              -javaagent:C:/byteman-3.0.3/lib/byteman.jar=script:C:/app/ECLSManagedConnectionFactory.btm,boot:C:/byteman-3.0.3/lib/byteman.jar:listener:true

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

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

              -Djava.net.preferIPv4Stack=true

              -Dorg.jboss.resolver.warning=true

              -Djboss.modules.system.pkgs=org.jboss.byteman

              -Djboss.server.default.config=cls.xml

           

          My server successfully starts up if lines 2 and 3 of my java_opts above aren't present, but the moment I add those in, the server simply doesn't start. Nothing to indicate what's happening goes to stdout or stderr. I get a message saying to check server.log for more info, but that file doesn't exist.

           

          What am I doing wrong? I've tried every combination of slash directions for the paths (on Windows 10 if that's important).

           

          Your -javaagent line is supposed to separate the various options passed to Byteman using a comma (,) separator. However, you have placed a colon (:) between the jar name which follows the boot: option and the following listener: option. Try replacing that with a comma and see what happens.

           

          I'm not sure why or even whether this would cause a hang on Windows but let's see what happens when you correct the options before we address that question.

           

          Taylor Marks wrote:

           

          (Also, does anyone here use Stack Overflow? I find the lack of a tag for byteman over there to be very odd... it would lead me to think that byteman is a very immature, niche product that nobody uses. If you want to pick up some rep and put an answer where it'll actually be found, post it on this same question over there: http://stackoverflow.com/questions/35849538/byteman-preventing-wildfly-8-1-0-from-starting .)

           

          Byteman is a very mature product (been available for download for over 7 years). It is somewhat niche in that it is used for a relatively specialised range of tasks when compared e.g. to say a compiler, IDE, build tool or whatever. However, it is is in use by many large organizations including by JBoss in about 30 development projects. So, in that sense no it is not in a niche.

           

          As with all JBoss projects, help for Byteman is provided here on the project's forum. If you post here you will be talking not just to other users but also to the developers  -- including me, the project lead. If you need advice regarding how to use any JBoss project software then I would suggest that the JBoss forums are the best place to ask -- all project developers are expected to take time to help users on the forums irrespective of whteher thye have a red Hat support contract.

           

          Red Hat developers don't generally care much to hang out, let alone acquire a reputation, on Stack Overflow. I am aware that a few people have answered a few Byteman queries there and, indeed, that some of those answers have been quite well informed. However, I expect you will find much better informed responses here.

           

          regards,

           

           

          Andrew Dinn

          • 2. Re: Byteman preventing Wildfly 8.1.0 from starting?
            Taylor Marks Newbie

            Your -javaagent line is supposed to separate the various options passed to Byteman using a comma (,) separator. However, you have placed a colon (:) between the jar name which follows the boot: option and the following listener: option. Try replacing that with a comma and see what happens.

            Hi Andrew,

             

            Here's the line from the beginning tutorial you wrote:
            set JAVA_OPTS="%JAVA_OPTS% -Dorg.jboss.byteman.transform.all -javaagent:%BYTEMAN_HOME%\lib\byteman.jar=script:thread.btm,boot:%BYTEMAN_HOME%\lib\byteman.jar:listener:true"

             

            The syntax appears to be:

             

            -javaagent:jarpath=script:btmpath,boot:jarpath:listener:true

             

            That's the exact syntax that I used, where jarpath is C:/byteman-3.0.3/lib/byteman.jar and btmpath is C:/app/ECLSManagedConnectionFactory.btm.

             

            I'm not sure what the proper syntax for paths on Windows is. How do I separate the drive name from the path, if not with a colon (or should I drop it entirely?). How do I split things up in a path? Forward slash? Backwards slash? Double backwards slash?

             

            Trying to check whether byteman works at all, I decided to remove those 2 lines from java_opts so that wildfly would start successfully.

             

            I want into task manager and found the PID was 3368.

             

            I did this:

             

            bminstall 3368

             

            Then this:

             

            bmsubmit -l C:\app\ECLSManagedConnectionFactory.btm

            That printed out a message saying that the rule was loaded properly. Just one problem: the server had already started up, so the class that I'm unsure of had already passed the point when it needed to be constructed, so I was unable to see if worked properly or not.

            Edit:

            I changed the line you complained about to this:
            -javaagent:/byteman-3.0.3/lib/byteman.jar=script:/app/ECLSManagedConnectionFactory.btm,boot:/byteman-3.0.3/lib/byteman.jar:listener:true


            Wildfly still fails to start up with these options provided.


            I wonder if perhaps I need to include byteman in the classpath somewhere?

            • 3. Re: Byteman preventing Wildfly 8.1.0 from starting?
              Taylor Marks Newbie

              Hi Andrew,

               

              I got this to work. A few things I discovered:

              #1 - The default startup xml file for wildfly suppresses all errors. Once I added failonerror="true" and set spawn to false, it dumped out a useful stack trace, informing me that the file \byteman-3.0.3\lib\byteman.jar:listener:true could not be found. This lead me to...
              #2 - There's a typo in your tutorial. As you mentioned in your post, there should be a comma between the path and listener:true, not a colon.

               

              Without you actually spelling out what the line should look like, though, I didn't realize the problem. So here it is for anyone else who wonders what the line should look like:

               

              -javaagent:/byteman-3.0.3/lib/byteman.jar=script:/app/ECLSManagedConnectionFactory.btm,boot:/byteman-3.0.3/lib/byteman.jar,listener:true

               

              Forward slashes work (even on Windows). Drive name isn't necessary. And put a comma, not a colon, between your boot jar and listener:true.

               

              Please correct that typo in your tutorial.

              • 4. Re: Byteman preventing Wildfly 8.1.0 from starting?
                Andrew Dinn Master

                HI Taylor,

                 

                I'm glad to see you got your code working. Please don't hesitate to ask if you have any other problems getting Byteman to do what you want.

                 

                Thank you very much for pointing out the typo. I have updated the tutorial accordingly.

                 

                You are correct that forward slashes work even on windows -- the JDK ensures that this path format is compatible on both Windows and Linux.

                 

                However, the path format used in the tutorial (employing a drive name (C:) and the backslash (\) separator) should also work -- it did so on the platforms I have tested Byteman on (Windows XP/Vista/7). Was there a problem in your deployment when you used that format? or was the file not found error solely related to extra text in the filename caused by the erroneous colon?

                 

                regards,

                 

                 

                Andrew Dinn