0 Replies Latest reply on Jun 8, 2011 2:57 PM by Andreas Oswald

    Trying to connect to an JBoss 4.2.1.GA org.jboss.system.server.ServerInfo with groovy without success results in "error during JRMP connection establishment"

    Andreas Oswald Newbie

      Hi there,

       

      to monitor FreeMemory in org.jboss.system.server.ServerInfo on a regular basis I would like to connect to 4.2.1.GA with the help of a groovy script and execute some actions in the groovy script if the FreeMemory goes under a critical value. Also I would like to log the FreeMemory over the time, which could be done in the groovy script as well.

       

       

      When using the jmx console with the browser I can show the wanted value as can be done with executing twiddle.

       

       

      {quote:title=Accessing from twiddle works fine}

      C:\Programme\jboss-4.2.1.GA\bin>twiddle -s vm-appsfs4p:1099 get "jboss.system:type=ServerInfo" FreeMemory

      FreeMemory=320676872

      {quote}

       

      I tried quite a few code snippets from the internet and tried different permutation of URL syntax

       

      {code}

      import java.lang.management.*

      import javax.management.ObjectName

      import javax.management.remote.JMXConnectorFactory as JmxFactory

      import javax.management.remote.JMXServiceURL as JmxUrl

       

      def serverUrl = "service:jmx:rmi:///jndi/rmi://vm-appsfs4p:1099/jmxrmi"

      String beanName = "jboss.system:type=ServerInfo"

       

      def server = JmxFactory.connect(new JmxUrl(serverUrl)).MBeanServerConnection

       

      def mbean = new GroovyMBean(server, beanName)

       

      println "Connected to:\n$dataSystem\n"

       

      println mbean.FreeMemory;

      {code}

       

      {quote:title=Here's what my output looks like}

      C:\temp>jmx.groovy

       

      Caught: java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.CommunicationException

      [Root exception is java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is:

              java.net.SocketException: Software caused connection abort: recv failed]

              at jmx.run(jmx.groovy:9)

      {quote}

       

      What am I doing wrong? Please be kind as those are my first experiments in this area.

       

      I'd be happy if someone could help me with this, thanks in advance for your help

       

      Take care

       

      Andreas