01 June 2006

More info on remote jconsole connections

[update] the bug has now been fixed in our 10.1.3.1 code line so this will work out of the box in the coming 10.1.3.1 release.

It turns out that jconsole (which I never found the src to!) supplies the jmx credentials as a String array, such as:

String s5 = userNameUrl.getText().trim();
String s7 = passwordUrl.getText();
String as[] = { s5, s7 };
connectionparameters.map.put("jmx.remote.credentials", as);

whereas we were expecting the credentials to be in a Map.

I don't like to leave things hanging ... so I made some changes to the effected classes in an isolated view just to see if I could get it to work -- fear not, Product Managers don't touch production code!


With the changes in place, I was then able to get jconsole to connect remotely to both a OC4J standalone and an Oracle Application Server instance using their respective URL forms:
  • service:jmx:rmi://[oc4j-host]:[oc4j-port]
  • service:jmx:rmi:///opmn://[opmn-host]:[opmn-port]/[oc4j-name]
I've logged a bug and try and work this fix into the 10.1.3.1 release.

I also found once I'd connected that I needed a couple of extra libraries on the client side to make jconsole work fully -- javax77.jar to get the Stats classes and dms.jar.

Here's the set of Oracle libraries required:
  • ${ORACLE_HOME}/j2ee/home/oc4jclient.jar
  • ${ORACLE_HOME}/j2ee/home/lib/adminclient.jar
  • ${ORACLE_HOME}/j2ee/home/lib/javax77.jar
  • ${ORACLE_HOME}/dms/lib/dms.jar

10 comments:

Anonymous said...

My what a smart fellow.

buttso said...

You're a funny man boston!

Demed said...

Thanks Steve for providing these details!
And my modest contribution: a script for lazy Windows users to launch JConsole against their local OC4J.


@REM ========================================================================
@REM Set these variables to reflect your local environment setup
@REM $Id: jconsole.bat 34 2006-09-01 23:05:15Z dlher $
@REM ========================================================================

@echo off
@REM === SET YOUR ENVIRONMENT HERE ===
@set ORACLE_HOME=D:\ORACLE\OC4J
@set JAVA_HOME=D:\jdk1.5.0_05
@REM === SHOULDN'T HAVE TO EDIT ANYTHING BEYOND THIS POINT ===

@set J2EE_HOME=%ORACLE_HOME%\j2ee\home
@set PATH=%JAVA_HOME%\bin;%PATH%
@set CLASSPATH=.;%JAVA_HOME%\lib\jconsole.jar;%JAVA_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

REM OC4J Standalone
%JAVA_HOME%\bin\jconsole -J-Djava.class.path=%CLASSPATH% -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 "service:jmx:rmi://localhost:23791"

Joong said...

I'm getting "URL path must begin with /jndi/ or /stub/ or /ior/: /opmn://dipowercrimson:6003/ipower" error on 10.1.3.1 application server. Do you know how to fix this issue?

buttso said...

gday Joong -- that typically means that you don't have the j2ee/home/admin_client.jar in the classpath of the JMX client.

Pas Apicella said...

Tested this today and it works well with 10.1.3.1. I found that all the forward slashes were required even though the "JMX Url" seemed incorrect it isn't. The format is exactly as specified.

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

I also found that adding the required start option at the container level is easily done in ASC from 10.1.3.1 onwards which is done from the "Server Properties" page with just two clicks. So in the end this was added for me automatically by ASC as a java start option for the container I wanted to connect remotely to.

-Dcom.sun.management.jmxremote

buttso said...

Thanks for the info Pas, glad it worked for you. Demed did us a favour with that script. Should look to see if we can get it added into the OC4J distribution somehow ...

Yogendra Rampuria said...

Hi,
I've read some posts from your blog and i musrt admit that they are truely informative. However I am stuck witha JMX/OC4J Cluster problem that have remained unsolved so far.

I want to connect to the JMX Server from a servlet that is running with oc4j.
What service url do i need to use? opmn based url is giving me exception, just like joong, does that mean i need to add the admin_client and related jars to my oc4j home startup parameters?

is it recommended?

Anonymous said...

Thanks very much - it works for me either .

Marwan Oweis said...

Thanks for the entries.
Following the steps mentioned in this blog I'm able to connect remotely to a standalone.

However, I am not able to connect remotely to the opmn. I get the following exception when trying to connect using JConsole:

Exception in thread "VMPanel.connect" java.lang.RuntimeException: Error getting OC4J Process for: opmn-JMX_sample+oc4j-10.200.200.234-23791-default
at oracle.oc4j.admin.jmx.shared.Oc4jOpmnRmiDomain.getOc4jProcs(Oc4jOpmnRmiDomain.java:616)
at oracle.oc4j.admin.jmx.shared.Oc4jOpmnRmiDomain.getPort(Oc4jOpmnRmiDomain.java:335)
at oracle.oc4j.admin.jmx.shared.Oc4jRmiDomain.getRmiPort(Oc4jRmiDomain.java:119)
at oracle.oc4j.admin.jmx.client.CoreRemoteMBeanServer.fetchMBeanServerEjbRemote(CoreRemoteMBeanServer.java:433)
at oracle.oc4j.admin.jmx.client.CoreRemoteMBeanServer.init(CoreRemoteMBeanServer.java:161)
at oracle.oc4j.admin.jmx.client.RemoteMBeanServer.init(RemoteMBeanServer.java:128)
at oracle.oc4j.admin.jmx.client.RemoteMBeanServer.getMBeanServer(RemoteMBeanServer.java:158)
at oracle.oc4j.admin.jmx.client.ClientMBeanServerProxyFactory.getMBeanServer(ClientMBeanServerProxyFactory.java:68)
at oracle.oc4j.admin.jmx.remote.rmi.RMIJMXConnectorImpl.getConnector(RMIJMXConnectorImpl.java:190)
at oracle.oc4j.admin.jmx.remote.JMXConnectorImpl.connect(JMXConnectorImpl.java:400)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
at sun.tools.jconsole.ProxyClient.tryConnect(ProxyClient.java:362)
at sun.tools.jconsole.ProxyClient.connect(ProxyClient.java:298)
at sun.tools.jconsole.VMPanel$2.run(VMPanel.java:280)
Caused by: oracle.ias.opmn.optic.OpticBadConnectException: Too few bytes (9) received from OPMN response
at oracle.ias.opmn.optic.OpmnPhone.rcvResponse(OpmnPhone.java:529)
at oracle.ias.opmn.optic.OpmnPhone.makePhoneCall(OpmnPhone.java:193)
at oracle.ias.opmn.optic.OpmnPhone.request(OpmnPhone.java:130)
at oracle.ias.opmn.optic.OpmnQuery.getBuf(OpmnQuery.java:347)
at oracle.ias.opmn.optic.OpmnQuery.getDom(OpmnQuery.java:467)
at oracle.ias.opmn.optic.OpmnQuery.getProc(OpmnQuery.java:615)
at oracle.ias.opmn.optic.OpmnQuery.getProc(OpmnQuery.java:709)
at oracle.oc4j.admin.jmx.shared.Oc4jOpmnRmiDomain.getOc4jProcs(Oc4jOpmnRmiDomain.java:592)
... 13 more

Any Ideas?
Thanks