Howto: JSR 160 support in JOnAS

The content of this document is the following:

  1. Target Audience and Rationale
  2. What is JSR 160?
  3. Connector servers created by JOnAS

Target Audience and Rationale

Starting with version 4.1.4, JOnAS provides support for remote connection to the MBean server in a standard way.

The target audience for this document is the management application developer or administrator who intends to use standard JMX RMI connectors to access the MBean Server running in a JOnAS server.

What is JSR 160?

The JSR 160 is a JMX Remoting specification which extends the JSR 3 specification by providing a standard API to connect to remote JMX-enabled applications.

Currently, JSR 160 has defined a mandatory connector based on RMI (that supports both RMI/JRMP and RMI/IIOP).

Support for JSR 160 connectors in JOnAS is based on the MX4J JMX implementation.

Connector servers created by JOnAS

Previous and current JOnAS versions implement a proprietary remote object that allows connection to the MBean server. This object is registered in JNDI under the name 'RMIConnector_jonasServerName'. It can be accessed using any of the communication protocols support by JOnAS (RMI/JRMP, RMI/IIOP, JEREMIE - see Choosing the Protocol).

JSR 160 support provides standard connector server objects. The JMX service creates one or several of these objects at start-up, depending on the JOnAS configuration (in this case, depending on the content of carol.properties file). To create a client connector, the client side needs to know the URL of the connector server. The following sections present URLs that can be used by the clients, depending on the protocol chosen.

Using a RMI/JRMP Connector

To use this connector, the jrmp protocol must be in the carol.protocols list.

The client must construct a JMXServiceURL using the following String, possibly modified based on the JOnAS-specific configuration: service:jmx:rmi:///jndi/rmi://host:1099/jrmpconnector_jonasServerName where host is the host on which the JOnAS server to be managed is running.

Then, a JMXConnector must be created and connected to the connector server using the JMX Remote API.

Example 1:

 
        Hashtable environment = null;   
        JMXServiceURL address = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://host:1099/jrmpconnector_jonas");
        JMXConnector connector = JMXConnectorFactory.newJMXConnector(address, environment);
        connector.connect(environment);

Using a RMI/IIOP Connector

This is used the same way as for JRMP, but the String being used to constuct the JMXServiceURL must adhere to the following model: "service:jmx:iiop:///jndi/iiop://host:2000/iiopconnector_jonasServerName"

Using a JEREMIE Connector

Using the JEREMIE protocol is more complicated because this proprietary protocol is not supported by MX4. However, it can still be used by employing an environment object initialized as described below.

Example 2:

 
        Hashtable environment = new Hashtable();
        environment.put(Context.PROVIDER_URL, "jrmi://host:2001");// use jeremie port number 
        environment.put(Context.INITIAL_CONTEXT_FACTORY, "org.objectweb.carol.jndi.spi.JEREMIEContextWrapperFactory");
        environment.put(Context.URL_PKG_PREFIXES, "org.objectweb.jonas.naming");
        JMXServiceURL address = new JMXServiceURL("service:jmx:rmi://host:2006/jndi/jeremieconnector_jonas");// use jeremie port number + 5
        JMXConnector connector = JMXConnectorFactory.newJMXConnector(address, environment);
        connector.connect(environment);