1 Reply Latest reply on Sep 15, 2003 10:50 AM by ranaaich

    Accessing an MBean using RMIClientConnectorImpl

    ranaaich Newbie

      Hello,

      Despite the fact this topic has been posted long time back - I have to broach upon the subject once again, since I have to know the correct way of doing things.

      I'm trying to connect the MBean in the JBOSS server(version 2.4.4) via a client ant task and I'm using the following code snippet:
      --------------------------------------
      Properties props = new Properties();
      props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
      props.put(Context.PROVIDER_URL, "jnp://localhost:1099");
      InitialContext ctx = new InitialContext(props);;
      String jndiName = "jmx:ranaa:rmi";

      String jndiEntry = (String)ctx.lookup(jndiName);
      ..... JMXConnector server = new RMIClientConnectorImpl(jndiEntry);
      ---------------------------------------

      However I'm getting the following error:

      [ejbBatchTask] java.lang.ClassCastException:
      org.jboss.jmx.server.RMIConnectorImpl_Stub
      [ejbBatchTask] at tool.task.EJBBatchTask.execute(EJBBatchTask.java:99)
      [ejbBatchTask] at
      org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:193)
      [ejbBatchTask] at org.apache.tools.ant.Task.perform(Task.java:341)
      [ejbBatchTask] at org.apache.tools.ant.Target.execute(Target.java:309)
      [ejbBatchTask] at org.apache.tools.ant.Target.performTasks(Target.java:336

      Any idea why I'm getting this exception.

      Thanks in advance!!!

      Regards,

      Rana

        • 1. Re: Accessing an MBean using RMIClientConnectorImpl
          ranaaich Newbie

          I found a solution to this.

          I'm using RMIConnector to connect to MBeanServer with the code as follows:

          Properties props = new Properties();
          props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
          props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
          props.put(Context.PROVIDER_URL, "localhost:1099");
          InitialContext ctx = new InitialContext(props);
          String serverName = InetAddress.getLocalHost().getHostName();
          String connectorName = "jmx:" + serverName + ":rmi";


          _server = (RMIConnector)ctx.lookup(connectorName);


          This code is working fine for me. So please consider this thread as closed.