3 Replies Latest reply on Feb 20, 2012 2:13 PM by Stian Thorgersen

    JMX connection within a WAR fails with "javax.naming.NameNotFoundException: rmi:"

    Stian Thorgersen Novice

      I have a web application that uses JMX to retrieve some information from another AS7 server. This worked fine in AS4 and AS6, but does not work on AS7.

       

      When trying to connect to the remote server the following exception is thrown:

       

      java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.NameNotFoundException: Name 'rmi:' not found in context ''
       at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:340)
       at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
       at com.arjuna.agility.test.tasks.api.ServiceAgreementManager.execute(ServiceAgreementManager.java:39)
       at com.arjuna.demodriver.run.auto.java.JavaRunner.execute(JavaRunner.java:65)
       at com.arjuna.demodriver.run.auto.AutoRunnerExecutor.run(AutoRunnerExecutor.java:24)
       at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
       at java.lang.Thread.run(Thread.java:662)
      Caused by: javax.naming.NameNotFoundException: Name 'rmi:' not found in context ''
       at org.jboss.as.naming.util.NamingUtils.nameNotFoundException(NamingUtils.java:109)
       at org.jboss.as.naming.InMemoryNamingStore$NodeTraversingVisitor.visit(InMemoryNamingStore.java:368)
       at org.jboss.as.naming.InMemoryNamingStore$ContextNode.accept(InMemoryNamingStore.java:307)
       at org.jboss.as.naming.InMemoryNamingStore.lookup(InMemoryNamingStore.java:162)
       at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:173)
       at org.jboss.as.naming.InitialContext.lookup(InitialContext.java:47)
       at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207)
       at javax.naming.InitialContext.lookup(InitialContext.java:392)
       at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1888)
       at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1858)
       at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:257)
       ... 7 more
      
      

       

      The code when executed outside of AS7 can connect to the AS7 server without any problems, but throws the above exception when executed from the WAR:

       

       

      JMXServiceURL serviceURL = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://127.0.0.1:1090/jmxrmi");
      HashMap<String, String> env = new HashMap<String, String>();
      JMXConnector connector = JMXConnectorFactory.connect(serviceURL, env);
      MBeanServerConnection mbs = connector.getMBeanServerConnection();