1 Reply Latest reply on Jun 28, 2007 12:38 PM by Rob Stryker

    Limited-scope Client classpath?

    Rob Stryker Master

      Hi... I'm trying to use JMX to get a value / attribute, specifically something like using twiddle to get

      get "jboss.system:type=Server" Started

      I'm having problems even getting an initial context properly. I'm wondering what's the limited number of jars I'd need to get the following to work. I don't want to include jbossall-client, for example.

      public static void main(String[] args) {
      InitialContext ctx;
      Properties props = new Properties(System.getProperties());
      props.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      props.put("java.naming.provider.url","jnp://localhost:1099");
      props.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
      try {
      ctx = new InitialContext(props);
      Object obj = ctx.lookup("jmx/invoker/RMIAdaptor");
      ctx.close();
      System.out.println(obj);
      } catch( NamingException ne ) {
      ne.printStackTrace();
      }
      }

      If I include jbossall-client on the classpath, it works fine. But if I only include jnp-client.jar, I get missing classes for jboss Logging.

      Any advice on using JMX in this fashion will be appreciated.

        • 1. Re: Limited-scope Client classpath?
          Rob Stryker Master

          I suppose the easiest way to do this with fewest dependencies is to not use JNDI but rather use JMX only.

          I think once I get an MBeanServerConnection I should be ok, so I guess my question is now, how do I discover the URL for such a connection?

          I'm currently reading a tutorial that includes the following:

          JMXServiceURL url = new JMXServiceURL(
          "service:jmx:rmi:///jndi/rmi://localhost:9999/server");
          JMXConnector jmxc = JMXConnectorFactory.connect(url, null);

          But that's a sun tutorial and not jboss-specific, so now my task is to figure out the service url.