31 May 2006

Establishing remote connections to OC4J with jconsole

I'm struggling with this task at the moment.

What I'm trying to do is to use the jconsole utility provided in JDK5 and establish a remote connection to an OC4J instance.

It works a treat when connecting using its local model -- just start OC4J with the following command:

java -Dcom.sun.management.jmxremote=true -jar oc4j.jar The JVM process running oc4j.jar will appear in the local connection tab and can be connected to.

However the remote connection model is presenting more of a challenge at the moment. Using the advanced tab, you can specify the direct JMX Service URL to connect the remote OC4J instance.

Now since OC4J uses its ORMI protocol for remote JMX connections, jconsole needs to be configured with the appropriate libraries and property settintgs to allow it to work over ORMI.

After a bit of trial and error, I captured what I think is the required command to launch jconsole and allow it to work as a remote OC4J client. The OC4J specific settings

jconsole
-J-Dcom.sun.management.jmxremote.ssl=false

-J-Dcom.sun.management.jmxremote.authenticate=true
-J-Djmx.remote.protocol.provider.pkgs=oracle.oc4j.admin.jmx.remote
-J-Djava.class.path=;%JAVA_HOME%\lib\jconsole.jar;/
%JAVA_HOME%lib\tools.jar;/
%ORACLE_HOME%\j2ee\home\lib\adminclient.jar

Using the advanced connection tab, you can specify the direct JMX Service URL to identify the target server.

To connect remotely to an OC4J process the URL is of the form

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



So all systems go .... except pressing the connect button results in an exception being thrown on the command line and the connection failing.

Exception in thread "JConsole.addUrl" java.lang.ClassCastException:[Ljava.lang.String;
at oracle.oc4j.admin.jmx.remote.rmi.RMIJMXConnectorImpl.getDomain(RMIJMXConnectorImpl.java:83)
at oracle.oc4j.admin.jmx.remote.JMXConnectorImpl.connect(JMXConnectorImpl.java:363)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
at sun.tools.jconsole.ProxyClient.(ProxyClient.java:117)
at sun.tools.jconsole.ProxyClient.getProxyClient(ProxyClient.java:87)
at sun.tools.jconsole.JConsole$2.run(JConsole.java:410)

Which at least when looking at the sunny side, shows that the client side configuration being used here must be close to the mark as OC4J client is being used and the exceptions are coming from OC4J JMX classes.

On the bummer side, it doesn't work!

I wanted to then see what is being passed into our RMIJMXConnector from jconsole and compare it with what we're expecting.

I hunted around for the source code for the JDK5/jconsole but couldn't seem to find it anywhere. Has anyone seen the source for jconsole?

The Mustang (JDK6) source snapshot release looks to include it, but I'm not using Mustang here.

Anyway, I'll keep digging and see how this can be made to work.


4 comments:

Anonymous said...

You are getting the error because you are not using ORMI protocol. Instead you seem to connect via RMI. The url that works is service:jmx:ormi://localhost:23791.

Good Luck!
Deepthi

Buttso said...

Thanks for the comment. It actually doesn't matter -- we have handlers for both RMI and ORMI in our client so they both map to the same thing.

I did get it to work, see my later post.

The issue was with setting the correct client side classpath and a bug we had to fix for the 10.1.3.1 release.

-steve-

Anonymous said...

Will Jconsole work if the same command is appended in start_oc4j.bat instead of starting JConsole with the mentioned arguments?

@echo
@set ORACLE_HOME=C:\jdevstudio1111tp2
@set JDK_HOME=%ORACLE_HOME%\jdk

@set J2EE_HOME=%ORACLE_HOME%\j2ee\home
@set PATH=%JAVA_HOME%\bin;%JDK_HOME%\bin;%PATH%
@set CLASSPATH=.;%JDK_HOME%\lib\jconsole.jar;%JDK_HOME%\lib\tools.jar;%J2EE_HOME%\lib\jms.jar;%J2EE_HOME%\lib\jndi.jar;%J2EE_HOME%\oc4jclient.jar;%J2EE_HOME%\lib\javax77.jar;%ORACLE_HOME%\j2ee\home\lib\adminclient.jar;%ORACLE_HOME%\lib\dms.jar;%JDK_HOME%;%J2EE_HOME%\admin_client.jar

set JAVA_COMMAND=
set VM_OPTS=-XX:MaxPermSize=256m -Djavax.xml.transform.TransformerFactory=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl -Djavax.xml.validation.SchemaFactory:http://www.w3.org/2001/XMLSchema=com.sun.org.apache.xerces.internal.jaxp.validation.xs.SchemaFactoryImpl -Djava.class.path=%CLASSPATH% -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true -Djmx.remote.protocol.provider.pkgs=oracle.oc4j.admin.jmx.remote

Anonymous said...

Hi,

if you want to connect to a remote OC4J goto http://wiki.oracle.com/page/How+to+use+JConsole%2C+JVisualVM+or+VisualVM+with+Oracle+Application+Server