6 Replies Latest reply on Nov 11, 2008 6:27 AM by michele.curioni

    service URL

      All

      When i use the following to connect to jboss via JMX

      JMXServiceURL server =
      new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:58098/jmxrmi");

      I get a stack trace, is this the correct url ? are there are docs on this ?

      Exception in thread "main" 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 javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:317)
       at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
       at com.db.abfo.loadrunner.client.jmx.JbossService.main(JbossService.java:52)
      Caused by: 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 com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:97)
       at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:185)
       at javax.naming.InitialContext.lookup(InitialContext.java:351)
       at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1817)
       at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1787)
       at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:259)
       ... 2 more
      Caused by: java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is:
       java.net.SocketException: Software caused connection abort: recv failed
       at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:273)
       at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171)
       at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:306)
       at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
       at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:93)
       ... 7 more
      Caused by: java.net.SocketException: Software caused connection abort: recv failed
       at java.net.SocketInputStream.socketRead0(Native Method)
       at java.net.SocketInputStream.read(SocketInputStream.java:129)
       at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
       at java.io.BufferedInputStream.read(BufferedInputStream.java:235)
       at java.io.DataInputStream.readByte(DataInputStream.java:241)
       at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:215)
       ... 11 more
      


        • 1. Re: service URL
          peterj

          I have been unable to come up with a url string that you can pass to JMXServiceURL for JBoss. Even googling did not yield anything. Instead, you need to use JNDI to look up the JMX server and go from there. Something like this:

          Hashtable env = new Hashtable();
           String factory="org.jnp.interfaces.NamingContextFactory";
           env.put(Context.INITIAL_CONTEXT_FACTORY, factory);
           String url1 = "jnp://localhost:1099";
           env.put(Context.PROVIDER_URL, url1);
           Context ctx = new InitialContext(env);
           MBeanServerConnection mconn =(MBeanServerConnection)ctx.lookup("jmx/invoker/RMIAdaptor");


          • 2. Re: service URL
            sk08

            The service URL is of this form

            service:jmx:rmi:///jndi/rmi://localhost:9900/jmxrmi

             InitialContext ctx = new InitialContext();
             MBeanServerConnection server = (MBeanServerConnection) ctx.lookup("jmx/invoker/RMIAdaptor");
             System.out.println(server);
             System.out.println("Total MBeans " + server.getMBeanCount());
            
            
             JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:9900/jmxrmi");
             JMXConnector connector = JMXConnectorFactory.connect(url);
             MBeanServerConnection connection = connector.getMBeanServerConnection();
             System.out.println(connection.getMBeanCount());
            


            The top bit as well as bottom bit both do similar things.

            However for JMX serviceURL you need to provide the port number to listen to. Note 1099 is RMI, the one below is JRMP

            set JAVA_OPTS=%JAVA_OPTS% "-Dcom.sun.management.jmxremote.port=9900"



            • 3. Re: service URL
              peterj

              The service URL was provided via this JIRA: https://jira.jboss.org/jira/browse/JBAS-3885

              The JIRA mentions 5.0 only.

              • 4. Re: service URL
                sk08

                The above works with JBoss 4.2.2GA as well as long as you provide the -D..jmxremote.port= option

                • 5. Re: service URL
                  michele.curioni

                  The connection works, but you will only see MBeans that are registered with the JVM MBeanServer, not the MBeans deployed in JBoss MBean Server.

                  I tried using -Djboss.platform.mbeanserver in JBoss 4.2 in order to have only one MBean server, but I got an exception at startup:

                  11:11:55,241 INFO [Server] Root Deployment Filename: jboss-service.xml
                  Failed to boot JBoss:
                  javax.management.InstanceNotFoundException: JMImplementation:service=LoaderRepository,name=Default
                  at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1010)
                  at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:804)
                  at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:784)
                  at org.jboss.system.server.ServerImpl.initBootLibraries(ServerImpl.java:628)
                  at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:429)
                  at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
                  at org.jboss.Main.boot(Main.java:200)
                  at org.jboss.Main$1.run(Main.java:508)
                  at java.lang.Thread.run(Thread.java:595)


                  Any idea how to fix this?

                  Thanks,
                  Michele

                  • 6. Re: service URL
                    michele.curioni

                    Sorry guys for the previous post,
                    I found the solution at::
                    http://www.jboss.org/community/docs/DOC-10521

                    Regards,
                    Michele