Show TOC Start of Content Area

Procedure documentation Connecting to an MBeanServer  Locate the document in its SAP Library structure

Use

You can connect to two types of MBeanServers: local and remote. This procedure describes how you can connect to either of the two servers.

Procedure

Connecting to a Local MBeanServer

The local MBeanServer on each cluster element is created by the JMX Adapter Service during startup. A reference is registered in the JNDI. You then lookup the MBeanServer from the JNDI. There is no need to create your own MBeanServer instance.

The following example shows the lookup from the JNDI:

import javax.naming.InitialContext;

import javax.management.MBeanServer;

...

// Lookup MBeanServer from the JNDI

InitialContext initCtx = new InitialContext();

MBeanServer mbs = (MBeanServer) initCtx.lookup("jmx");

 

Connecting to a Remote MBeanServer

Clients running outside the cluster cannot lookup the MBeanServer directly, since it is neither Remote nor Serializable. They have to use an MBeanServerConnection provided by the RMI-P4 JMX Connector. MBeanServerConnectionis a super-interface of MBeanServer. The MBeanServerConnection includes only those MBeanServer methods that make sense in a remote scenario. The following example demonstrates the creation of a connection:

import java.util.Properties;

import javax.naming.Context;

import com.sap.jmx.remote.JmxConnectionFactory;

...

// set the connection properties for the RMI-P4 connection

Properties connectionProperties = new Properties();

connectionProperties.setProperty(Context.INITIAL_CONTEXT_FACTORY,

               "com.sap.engine.services.jndi.InitialContextFactoryImpl");

connectionProperties.setProperty(Context.PROVIDER_URL, "<host-name>:<p4-port>");

connectionProperties.setProperty(Context.SECURITY_PRINCIPAL, "<user-name>");

connectionProperties.setProperty(Context.SECURITY_CREDENTIALS, "<password>");

// create the MBeanServerConnection

MBeanServerConnection mbsc = JmxConnectionFactory.getMBeanServerConnection(JmxConnectionFactory.
PROTOCOL_ENGINE_P4,
connectionProperties);

 

Note

If you are either accessing a local MBeanServer from an application, or using the RMI-P4 JMX Connector, you have to be logged in with a user in the default administrator role.

 

 

End of Content Area