6 Replies Latest reply on Dec 1, 2006 7:41 AM by Dimitris Andreadis

    JMX RMI Connector from JDK1.5

    Wen Gong Newbie

      Hi,

      I'm interested in using JMX RMI connector from JDK1.5 to make remote connections and invocations from JBOSS MBeans.

      Does JBOSS4.0.2 support JDK1.5 for this purpose?

      There is also a download for JavaTM Management Extensions (JMXTM) Remote API reference implementation, can I use this to create a client and expect it to connect to JBOSS server using the RMI connector?

      Thanks.

      Wen

        • 1. Re: JMX RMI Connector from JDK1.5
          Peter Johnson Master

          Yes, you can easily write a Java app to access MBeans within JBoss, and you don't need JDK 5 to do it. Here is some simple code that prints out the attribute value of a particular mbean:

          package foo.bar;
          import java.util.Hashtable;
          import javax.management.MBeanServerConnection;
          import javax.management.ObjectName;
          import javax.naming.Context;
          import javax.naming.InitialContext;
          public class MBean {
           public static void main(String[] args) throws Exception {
           Hashtable env = new Hashtable();
           String factory = "org.jnp.interfaces.NamingContextFactory";
           env.put(Context.INITIAL_CONTEXT_FACTORY, factory);
           String url1 = "jnp://localhost:1099";
           env.put(Context.PROVIDER_URL, url1);
           Context ctx = new InitialContext(env);
           MBeanServerConnection mconn = (MBeanServerConnection)ctx.lookup("jmx/invoker/RMIAdaptor");
           ObjectName name = new ObjectName("jboss.jca:name=ds/ProductDS,service=ManagedConnectionPool");
           Object val = mconn.getAttribute(name, "InUseConnectionCount");
           System.out.println(name + "\n\tInUseConnectionCount=" + val);
           }
          }


          Note that the MBeanServerConnection is accessed via JNDI, and not via a JMXServiceURL. (My search for a way to use a JMXServiceURL never turned up any schemes that worked.)

          • 2. Re: JMX RMI Connector from JDK1.5
            Wen Gong Newbie

            Hi Peter,

            Thanks for the suggestion. Do you by any chance know if this approach is applicable across different JMX containers, for example, WebLogic Server? Anther issue might be the registration of notifications remotely -- can I register for notifications remotely with the MBeanServerConnection obtained in this manner?

            The other reason I'd like to use native JMX RMI connector is that I can access other JMX container as well.

            It appears remoting service from JBOSS 5 might be the answer to this. see http://wiki.jboss.org/wiki/Wiki.jsp?page=JMX_Remoting_service_configuration

            I'm not sure when this feature will be backported into JBOSS4.x though.

            Thanks.

            Wen

            • 3. Re: JMX RMI Connector from JDK1.5
              Peter Johnson Master

              Will this approach work with other app servers? Probably. I am in the middle of preparing a presentation for a conference in December (paper deadline is June 16th!) and I cover JMX (which is why I had a small example app already prepared). I was going to try it with other app servers so I could give the audience some ideas on accessing other app servers, though that won't make the deadline cuz the week of June 12 I will be partying in Vegas (I mean, "attending JBossWorld and learning about all the latest JBoss-related technologies"; hope my boss doesn't read this forum!)

              Not sure on registering for notifications, though.

              • 4. JMX and Security -- Re: JMX RMI Connector from JDK1.5
                Morten Haavaldsen Newbie

                Hi,

                I have protected the jmx-console at installation of servr(4.04-GA):

                Have anybody got it working programmatically logging in and accessing MBeans.
                A code example would help a lot since doc is hard to come across....

                Trying to access MBeans gives:

                Exception in thread "main" java.lang.SecurityException: Failed to authenticate principal=null, securityDomain=jmx-console
                at org.jboss.jmx.connector.invoker.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:97)
                at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)



                • 5. Re: JMX RMI Connector from JDK1.5
                  Marilen Corciovei Newbie

                  You can find an example using jmx remote invocation with secured console here http://www.len.ro/work/articles/jboss/jmx-invocation-with-secured-console/