The system management functionality of WebSphere Application Server uses Java Management Extensions (JMX). Therefore, the WebSphere Application Server administrative console and wsadmin scripting client use JMX. In addition, you can use the JMX API to provide custom client programs or contribute custom MBeans.
A common way to enable local JMX access on these JVMs is to include the -Dcom. sun. management. jmxremote option on the command line when you start the JVM.
Following information is for Websphere 6.1 on Windows.
First of all, the magic URL to connect to the MBean server is:
service:jmx:iiop://<host>:<port>/jndi/JMXConnector
If you have a default Websphere installation, the JNDI port number will likely be 2809, 2810, ... depending on how many servers there are installed on one system and the specific one you want to connect to. To be sure, when starting Websphere, check the logs, as it will dump a line like
0000000a RMIConnectorC A ADMC0026I: The RMI Connector is available at port 2810
If you don't get this line, open the Websphere admin console and go to
Application servers > server1 > Administration Services > JMX connectors
to see if you need to add or change the config.
Second important bit of information is that the following JAR is always needed when doing JMX with the server:
com.ibm.ws.admin.client_6.1.0.jar
You can find this JAR in the the runtimes
directory of Websphere. Whatever you do, whether programmatically accessing MBeans on Websphere, or using JConsole, and so on, use the magic URL and always include this JAR.
For the remainder of this answer, assume that Websphere is installed in D:\prog\was61.
To run JConsole, type in the following:
D:\prog\was61\java\bin>jconsole -J-Djava.class.path=d:\prog\was61\java\lib\tools.jar;D:\prog\was61\runtimes\com.ibm.ws.admin.client_6.1.0.jar
Then go to the "Advanced" tab and type in the magic JMX URL. Press connect and you should see the MBeans appear.
Using a Sun JDK is an entirely different matter. You need one extra JAR that is in the lib of the IBM JDK but not Sun's (ibmorb.jar), and maybe the following command may work for you:
C:\Program Files\Java\jdk1.5.0_11\bin>jconsole -J-Djava.class.path="c:\Program Files\Java\jdk1.5.0_11\lib\jconsole.jar";"c:\Program Files\Java\jdk1.5.0_11\lib\tools.jar";D:\prog\was61\runtimes\com.ibm.ws.admin.client_6.1.0.jar;D:\prog\was61\java\jre\lib\ibmorb.jar
I say maybe, because it didn't work for me. I got a nice jndiUnavailCommErr error message, since it expected something on port 2809 while my Websphere installation is listening on 2810, although I correctly specified port 2810 in the JMX URL. But, if you adapt the paths to point to your Sun JDK, it might work for you. It's the closest I ever got to connecting to Websphere using Sun's JDK.
Final note: I tried a solution based on RMI, there is also a SOAP connector available but haven't tried it.
As always with J2EE, Websphere and stuff: good luck, you'll need it.
It is simple. Just start Websphere with the following JMX parameters:
-Djavax.management.builder.initial=
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.port=1099
Then start JConsole or VisualVM and connect to localhost:1099
Since i am not allowed to post a proof screenshot i post the information from the visualvm "overview tab".
PID: 12568 Host: localhost Main class: <unknown> Arguments: <none> JVM: IBM J9 VM (2.3, J2RE 1.5.0 IBM J9 2.3 Windows XP x86-32 j9vmwi3223-20100808 (JIT enabled) J9VM - 20100629_60535_lHdSMr JIT - 20100623_16197_r8 GC - 20100211_AA) Java: version 1.5.0, vendor IBM Corporation Java Home: C:\Program Files\IBM\SDP\runtimes\base_v61\java\jre JVM Flags: <none> Heap dump on OOME: disabled
Maybe it's a little offtopic, but I have found a way to connect to WAS 7.0 JMX server from JConsole. No server setup is required, no AppClient, only some JARs and a little client setup.
Use the following script
@echo off
set HOST=<host>
set PORT=2809
set WAS_HOME=D:/Programy/IBM/WebSphere/AppServer
set THIS_DIR=E:/Home/Bogus/Pulpit
set CLIENTSAS=-Dcom.ibm.CORBA.ConfigURL=file:/%THIS_DIR%/sas.client.props
set PROVIDER=-Djava.naming.provider.url=corbaname:iiop:%HOST%:%PORT%
set PROPS=
set PROPS=%PROPS% %CLIENTSAS%
set PROPS=%PROPS% %PROVIDER%
set CLASSPATH=
set CLASSPATH=%CLASSPATH%;%WAS_HOME%\java\lib\tools.jar
set CLASSPATH=%CLASSPATH%;%WAS_HOME%\runtimes\com.ibm.ws.admin.client_7.0.0.jar
set CLASSPATH=%CLASSPATH%;%WAS_HOME%\runtimes\com.ibm.ws.ejb.thinclient_7.0.0.jar
set CLASSPATH=%CLASSPATH%;%WAS_HOME%\runtimes\com.ibm.ws.orb_7.0.0.jar
set CLASSPATH=%CLASSPATH%;%WAS_HOME%\java\lib\jconsole.jar
set URL=service:jmx:iiop://%HOST%:%PORT%/jndi/JMXConnector
@echo on
:: %WAS_HOME%\java\bin\
java -classpath %CLASSPATH% %PROPS% sun.tools.jconsole.JConsole %URL%
If the target server has administrative security disabled, comment out CLIENTSAS and PROVIDER lines.
If the security is enabled, you will also need sas.client.props file to be put in THIS_DIR directory. The template file can be found under WAS_profile\properties directory. You will have to do a little setup. Here is an excerpt from my sas.client.props
com.ibm.CORBA.securityEnabled=true
com.ibm.CORBA.authenticationTarget=BasicAuth
com.ibm.CORBA.authenticationRetryEnabled=true
com.ibm.CORBA.authenticationRetryCount=3
com.ibm.CORBA.validateBasicAuth=true
com.ibm.CORBA.securityServerHost=
com.ibm.CORBA.securityServerPort=
com.ibm.CORBA.loginTimeout=300
com.ibm.CORBA.loginSource=prompt
com.ibm.CORBA.loginUserid=
com.ibm.CORBA.loginPassword=
com.ibm.CORBA.krb5ConfigFile=
com.ibm.CORBA.krb5CcacheFile=
com.ibm.CSI.performStateful=true
com.ibm.CSI.performClientAuthenticationRequired=false
com.ibm.CSI.performClientAuthenticationSupported=true
# SET ALL THE FOLLOWING VALUES TO FALSE
com.ibm.CSI.performTLClientAuthenticationRequired=false
com.ibm.CSI.performTLClientAuthenticationSupported=false
com.ibm.CSI.performTransportAssocSSLTLSRequired=false
com.ibm.CSI.performTransportAssocSSLTLSSupported=false
com.ibm.CSI.performMessageIntegrityRequired=false
com.ibm.CSI.performMessageIntegritySupported=false
com.ibm.CSI.performMessageConfidentialityRequired=false
com.ibm.CSI.performMessageConfidentialitySupported=false
# COMMENT THIS OUT
#com.ibm.ssl.alias=DefaultSSLSettings
com.ibm.CORBA.requestTimeout=180
OK :)
After connecting, the login popup will appear. Type your admin user and password (user & pw are not required on the connection dialog in JConsole)
You may run the JConsole from IBM JDK, or Sun JDK. For IBM, no other setup is required. However, for Sun you may need to put orb.properties file in your home directory. The file can be found in com.ibm.ws.ejb.thinclient_7.0.0.jar.
I couldn't get this to work. All I got was
The connection to username@service:jmx:iiop//localhost:2809/jndi/JMXConnector did not succeed. Would you like to try again?
I did however get it working by doing the following:
com.sun.management.jmxremote.port=9999 com.sun.management.jmxremote.authenticate=false com.sun.management.jmxremote.ssl=false
But none of the usefull mbeans show up..?
I found that in order to connect to WAS 6.1 using the Sun JDK JConsole, in addition to the com.ibm.ws.admin.client_6.1.0.jar
JAR file, I had to also include the following 3 JARs on the boot class path when starting JConsole:-
ibmorbapi.jar
ibmorb.jar
ibmcfw.jar
These can be found in the java\jre\lib directory of websphere.
For example on windows, if you copy all the four JARs listed above to a directory of your choice (i've copied them to C:\packages\was61-jmx in the example below), you can use a batch file like the following to start JConsole:-
set JAVA_HOME=C:\Progra~1\Java\jdk1.5.0_20
set WAS6.1_JARS=C:\packages\was61-jmx
set BOOTJARS=%WAS6.1_JARS%\ibmorbapi.jar
set BOOTJARS=%BOOTJARS%;%WAS6.1_JARS%\ibmorb.jar
set BOOTJARS=%BOOTJARS%;%WAS6.1_JARS%\ibmcfw.jar
set CLASSPATH=%WAS6.1_JARS%\com.ibm.ws.admin.client_6.1.0.jar
set CLASSPATH=%CLASSPATH%;%JAVA_HOME%\lib\tools.jar
set CLASSPATH=%CLASSPATH%;%JAVA_HOME%\lib\jconsole.jar
%JAVA_HOME%\bin\jconsole -J-Xbootclasspath/p:%BOOTJARS% -J-Djava.class.path=%CLASSPATH%
This worked for me for jdk 1.5 and 1.6 versions of the Sun Jconsole.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With