3 Replies Latest reply on Nov 25, 2013 10:54 AM by Amit Telang

    Configuring remote JMX with jboss-client.jar

    David Pugh Newbie

      Hello, Im having a bit of a problem getting remote JMX working with Jboss-7.1.0.Final.

      I know that there is a different way of making the remote JMX call as such:

       

      service:jmx:remoting-jmx://" + serveName + ":9999

       

      I also know that you have to add jboss-client-7.1.0.Final to the classpath of the project that is acting as the client and making the remote JMX call.

       

      I created a little experimental project in my IDE (IntelliJ) using Grails.  I added jboss-client-7.1.0.Final directly to my Grails's lib folder. When I run the

      project directly from my IDE, the project works, and I can make the remote JMX call.

       

      When I package the project as a war and deploy to my local Jboss 7.1.0.Final server I get these errors.

       

       

      11:41:34,012 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-13) Context initialization fail

      ed: org.springframework.beans.factory.access.BootstrapException: Error executing bootstraps; nested exception is org.cod

      ehaus.groovy.runtime.InvokerInvocationException: java.io.IOException: Unable to load configuration class org.jboss.logma

      nager.PropertyConfigurator

              at org.codehaus.groovy.grails.web.context.GrailsContextLoader.createWebApplicationContext(GrailsContextLoader.ja

      va:87) [grails-web-1.3.7.jar:1.3.7]

              at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197) [spring-web-3

      .0.5.RELEASE.jar:3.0.5.RELEASE]

              at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) [spri

      ng-web-3.0.5.RELEASE.jar:3.0.5.RELEASE]

              at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.10.Fin

      al.jar:]

              at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.10.Final.jar:]

              at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.0.Fina

      l.jar:7.1.0.Final]

              at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

              at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0]

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0]

              at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0]

      Caused by: org.codehaus.groovy.runtime.InvokerInvocationException: java.io.IOException: Unable to load configuration cla

      ss org.jboss.logmanager.PropertyConfigurator

              at grails.spring.BeanBuilder.invokeBeanDefiningClosure(BeanBuilder.java:723) [grails-spring-1.3.7.jar:1.3.7]

              at grails.spring.BeanBuilder.beans(BeanBuilder.java:573) [grails-spring-1.3.7.jar:1.3.7]

              at grails.spring.BeanBuilder.invokeMethod(BeanBuilder.java:519) [grails-spring-1.3.7.jar:1.3.7]

              ... 6 more

      Caused by: java.io.IOException: Unable to load configuration class org.jboss.logmanager.PropertyConfigurator

              at org.jboss.logmanager.LogManager.construct(LogManager.java:266) [jboss-client-7.1.0.Final.jar:7.1.0.Final]

              at org.jboss.logmanager.LogManager.readConfiguration(LogManager.java:244) [jboss-client-7.1.0.Final.jar:7.1.0.Fi

      nal]

              at org.jboss.logmanager.LogManager$readConfiguration.call(Unknown Source) [:1.2.2.GA]

              ... 9 more

      Caused by: java.lang.ClassCastException: Cannot cast org.jboss.logmanager.PropertyConfigurator to org.jboss.logmanager.C

      onfigurator

              at java.lang.Class.cast(Class.java:3005) [rt.jar:1.7.0]

              at org.jboss.logmanager.LogManager.construct(LogManager.java:264) [jboss-client-7.1.0.Final.jar:7.1.0.Final]

              ... 11 more

       

       

       

      So obviously there are errors when I try and package it directly with the grails war.

       

      I was looking for different ways to add the jboss-client jar to the classpath and I read this article about JMX with Jboss 7.1.0

       

      https://docs.jboss.org/author/display/AS71/JMX+subsystem+configuration

       

      In that article they say you can set jboss-client.jar in the classpath as such:

       

       

      !/bin/bash

      # specify your AS7 folder
      export YOUR_AS7_HOME=~/as7

      java -classpath $YOUR_AS7_HOME/bin/client/jboss-client.jar:./ JMXExample

       

       

      Locally, I'm running on Windows, although when I deploy to my companies server's it will be in a Linux environment

       

      I really wasn't sure about this    java -classpath $YOUR_AS7_HOME/bin/client/jboss-client.jar:./ JMXExample     Line.

      I know that my jboss-client-7.1.0.Final jar is located in  as7home/bin/client, but the rest confuses me. My class in the war is called SogoXmlController.groovy.

      How would I reference this in the line above?

      I removed jboss-client-7.1.0.Final from the Grails war's lib folder and tried adding this to my standalone.conf.bat file :

      set java -classpath /bin/client/jboss-client-7.1.0.Final.jar:./ SogoXmlController

      But this didn't work because when I tried to make the JMX call I got the error:

       

      java.net.MalformedURLException: Unsupported protocol: remoting-jmx

       

      which is the standard error when jboss-client jar is not added to your classpath.

       

      Even if I got something like

       

      set java -classpath /bin/client/jboss-client-7.1.0.Final.jar:./ SogoXmlController

       

      working (like I just needed to change the classpath setting a tab bit)

      I still have other classes that make seperate remote JMX calls.Would I have multiple of these "java -classpath" s  added to my standalone.conf (or for windows standalone.conf.bat)? Wouldnt they overwrite each other?

       

      I would love to just be able to add jboss-client-7.1.0.Final to my Grail's lib folder and be done with it (like I did when I ran it from my IDE directly), but I get those

      java.io.IOException and java.lang.ClassCastException

      exceptions.

       

      Please help me.

       

      Sincerely,

       

      David Matthew Pugglesworth

        • 1. Re: Configuring remote JMX with jboss-client.jar
          David Pugh Newbie

          So I've been taking a closer look at this problem and I noticed a README.txt file in the folder where jboss-client-7.1.0.Final.jar is located.

          The README file says this:

           

          Maven users should not use this jar, but should use the following BOM dependencies instead

           

              <dependencies>

                  <dependency>

                      <groupId>org.jboss.as</groupId>

                      <artifactId>jboss-as-ejb-client-bom</artifactId>

                      <type>pom</type>

                  </dependency>

                  <dependency>

                      <groupId>org.jboss.as</groupId>

                      <artifactId>jboss-as-jms-client-bom</artifactId>

                      <type>pom</type>

                  </dependency>

              </dependencies>

           

          This is because using maven with a shaded jar has a very high chance of causing class version conflicts, which is why

          we do not publish this jar to the maven repository.

           

           

          I am using maven to build my project and decided to use  jboss-as-ejb-client-bom  and jboss-as-jms-client-bom pom dependencies in my maven pom for my grails project that does the remote JMX call.

          I added the 2 pom dependencies and after building, all of the dependencies that the README file said that should be satisfied were downloaded.

          These include

          org.jboss.spec.javax.jms:jboss-jms-api_1.1_spec

          org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec

          org.jboss.spec.javax.ejb:jboss-ejb-api_3.1_spec

          org.jboss:jboss-remote-naming

          org.jboss.logging:jboss-logging

          org.jboss.marshalling:jboss-marshalling

          org.jboss.marshalling:jboss-marshalling-river

          org.jboss.remoting3:jboss-remoting

          org.jboss.sasl:jboss-sasl

          org.jboss.xnio:xnio-api

          org.jboss.xnio:xnio-nio

          org.jboss.netty:netty

          org.hornetq:hornetq-core-client

          org.hornetq:hornetq-jms-client

           

          The only exception being org.jboss.remoting3:remoting-jmx.

          The remoting-jmx dependency was not satisfied by jboss-as-ejb-client-bom and  jboss-as-jms-client-bom.

          When I tried to deploy my grails war without the remoting-jmx I didn't get the errors mentioned above, but when I tried to perform the remote JMX call I got the java.net.MalformedURLException: Unsupported protocol: remoting-jmx error.

          I specifically added the org.jboss.remoting3:remoting-jmx

          dependency to my pom on top of the

          jboss-as-ejb-client-bom and  jboss-as-jms-client-bom pom dependencies

          and then I got the

          java.io.IOException and java.lang.ClassCastException

          errors as listed above.

           

          Just for your information, I also tried this with the newer version of jboss 7.1.1.Final, with the correct

          jboss-as-ejb-client-bom and  jboss-as-jms-client-bom's and the correct org.jboss.remoting3:remoting-jmx

          dependency that correlates to this version, and I get the same results.

           

          Please help me with my issue.

           

          David

          • 2. Re: Configuring remote JMX with jboss-client.jar
            David Pugh Newbie

            Hello.  I have managed to fix this issue.

            The problem was with the version of Grails that I was using.

            I was using grails 1.3.7.

            After I upgraded to grails 2.0, I was able to use the jboss-client jar that came with the jboss 7 application server.

            I just added it directly to my grails's lib folder.

            I didn't even have to resort to adding the jboss-client to my pom, after the

            upgrade it just worked.

            • 3. Re: Configuring remote JMX with jboss-client.jar
              Amit Telang Newbie

              With Maven how to resolve this. I am facing issue when Jboss-client I can not add with Maven and using the steps mentioned in the README.txt.

              But while doing so I am getting issue at the time of Inital Context.

              Hashtable<String, String> env = new Hashtable<String, String>();

                env.put("java.naming.factory.initial",

                  "org.jboss.naming.remote.client.InitialContextFactory");

                env.put("java.naming.provider.url", jmsServerURL);

               

              Thanks,

              Amit