29 June 2006

Client setup for connecting to OC4J using JSR160

When connecting from remote JMX clients to OC4J using JSR160, there's a couple of things to keep in mind.

  1. For OC4J, the Service URL specifies the use of the RMI protocol

    service:jmx:rmi://[oc4j-host]:[oc4j-ormiport]


  2. For OracleAS, the Service URL additionally specifies the use of the OPMN mechanism to obtain the ORMI port of the specified OC4J instance

    service:jmx:rmi:///opmn://[opmn-host]:[opmn-port]/[oc4j-name]

  3. The client needs to be told where to locate the RMI implementation.

    For programatic clients, this is done using the environment passed to the JMXConnectorFactory

    Hashtable env= new Hashtable();

    env.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES,
    "oracle.oc4j.admin.jmx.remote"
    );

    Hashtable credentials= new Hashtable();

    credentials.put(JMXConnectorConstant.CREDENTIALS_LOGIN_KEY,"oc4jadmin");
    credentials.put(JMXConnectorConstant.CREDENTIALS_PASSWORD_KEY,"welcome1");

    env.put(JMXConnector.CREDENTIALS, credentials);

    jmxCon = JMXConnectorFactory.newJMXConnector(serviceUrl, env);

    For pre-built clients, this is done using a System property:

    -Djmx.remote.protocol.provider.pkgs=oracle.oc4j.admin.jmx.remote

  4. The client classpath needs to include the $ORACLE_HOME/j2ee/home/admin_client.jar library. This library contains references to all the libraries needed to establish remote JMX connections in its Manifest.mf Class-Path entry. It's a nice one-stop shop.
This combination of things usually solves most of the problems I get asked about in this area.

The OC4J J2EE Developer's Guide has a good section on remote connections.

3 comments:

Anonymous said...

Hi Buttso,

Thanks for the blog. It really helped me to resolve JMX Connection issue. Keep up on blogging with some more gooddies.

Thanks again.

Rajesh

Buttso said...

Thanks Rajesh, I'm glad it was able to help you.

-buttso-

Kamatcho said...

Sending a big thanks from Melbourne :). the blog covers points which is not clear or may be does not exist in Oracle documentation. Thanks again, cheeers