3 Replies Latest reply on Oct 26, 2010 5:39 AM by Fran GJ

    Can't make JMX connection to Message Broker.

    Peter Chandler Master

      I am using apache-servicemix-4.2.0-fuse-01-00 and trying to establish a JMX client connection to ActiveMQ. I am getting "javax.naming.NameNotFoundException: jmxrmi" on the connect() method. Important to note the below code works find in ServiceMix 4.1.0.0-fuse.   Help. Any ideas? details below.

       

      ServiceMix/ActiveMQ seems to start fine.

      karaf@root> list | grep jmx
      [  17] [Active     ] [            ] [       ] [   30] org.osgi.impl.bundle.jmx (4.2.0.200907080519)
      
      karaf@root> list | grep activemq
      [  87] [Active     ] [            ] [       ] [   60] activemq-core (5.3.0.fuse-01-00)
      [  88] [Active     ] [            ] [       ] [   60] activemq-ra (5.3.0.fuse-01-00)
      [  89] [Active     ] [            ] [       ] [   60] activemq-console (5.3.0.fuse-01-00)
      [  90] [Active     ] [            ] [       ] [   60] activemq-pool (5.3.0.fuse-01-00)
      [ 141] [Active     ] [            ] [       ] [   60] activemq-broker.xml (0.0.0)
      

       

      Java Code

      
          // Service Mix username/password
          String username = "smx"; //Note: for activeMQ install use: amq
          String password = "smx"; //Note: for activeMQ install use: amq
      
          // set the credentials
          Map<String, String[]> env = new HashMap<String, String[]>();
          String[] credentials = new String[] { username, password };
          env.put(JMXConnector.CREDENTIALS, credentials);
          
          amqJmxUrl = "service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi";
          System.out.println("URL is : "+amqJmxUrl);
          // get the connection.
          try {
              connector = JMXConnectorFactory.newJMXConnector(new JMXServiceURL(amqJmxUrl), env);
              connector.connect(); 
      

       

      Exception:

      URL is : service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
      java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.NameNotFoundException: jmxrmi
           at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:338)
           at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:227)
           at com.my.company.jmx.client.jmxtestclient.connect(jmxtestclient.java:89)
           at com.my.company.jmx.client.jmxtestclient.main(jmxtestclient.java:43)
      Caused by: javax.naming.NameNotFoundException: jmxrmi
           at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:99)
           at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:185)
           at javax.naming.InitialContext.lookup(InitialContext.java:392)
           at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1886)
           at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1856)
           at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:257)
           ... 3 more
      java.lang.NullPointerException
           at com.my.company.jmx.client.jmxtestclient.main(jmxtestclient.java:45)
      

       

      ?