1 Reply Latest reply on Aug 21, 2002 11:54 AM by Adrian Brock

    RMIConnector in standalone agents

    John Newbie

      Is it possible to run multiple standalone (in own JVM) agents using the RMI connector available in the 2.4.6 release?

      I create an RMI Connector in the agent and pass it a unique JNDI name. In the client, I do find the right connector, but when I try to invoke on the dummy MBean in the agent, I get an instance not found exception.

      Please help thanks.


      agent code snippet:
      MBeanServer lServer = MBeanServerFactory.createMBeanServer();
      ObjectName lConnectorName = new ObjectName( lServer.getDefaultDomain(), "service", "RMIConnector");
      lServer.createMBean("org.jboss.jmx.server.RMIConnectorService",lConnectorName,new Object [] { domain },new String []{ "java.lang.String" });
      lServer.invoke( lConnectorName, "init", new Object[] {}, new String[] {} );
      lServer.invoke( lConnectorName, "start", new Object[] {}, new String[] {} );
      ObjectName myMbean = new ObjectName ( lServer.getDefaultDomain(), "service", "AskMe");
      lServer.createMBean( "DummyAsk", myMbean, new Object [] { }, new String [] { });
      System.out.println("timestamp = " + (Long)lServer.invoke(myMbean, "getTimeStamp", new Object[] {}, new String[] {} ));


      sample client snippet:
      Hashtable lProperties = lContext.getEnvironment();
      ConnectorFactoryImpl.JBossConnectorTester lTester = new ConnectorFactoryImpl.JBossConnectorTester();
      Iterator lConnectors = (Iterator) lLocalServer.invoke( lFactoryInstance.getObjectName(),"getConnectors",new Object[] { lProperties, lTester },new String[] { lProperties.getClass().getName(),ConnectorFactoryImpl.IConnectorTester.class.getName() });
      int theIndex = -1;
      while( lConnectors.hasNext() )
      {
      ConnectorFactoryImpl.ConnectorName lName = (ConnectorFactoryImpl.ConnectorName) lConnectors.next();

      if ( (lName.getJNDIName()).endsWith(":"+args[0])) { theIndex=i;} // searching for my specific jndi name connector
      i++;
      }
      if ( theIndex < 0 ) {
      System.out.println("can't find connector: " + args[0]);
      System.exit(1);
      }
      final ConnectorFactoryImpl.ConnectorName lConnectorName = (ConnectorFactoryImpl.ConnectorName) lTemp.elementAt(theIndex);

      System.out.println("connector name = " + lConnectorName);

      // create a connection to the remote MBeanServer...
      JMXConnector lConnector = (JMXConnector) lLocalServer.invoke( lFactoryInstance.getObjectName(),
      "createConnection",
      new Object[] { lConnectorName },
      new String[] { lConnectorName.getClass().getName() } );