views:

12539

answers:

9

I would like to use JConsole to monitor my Websphere application, but I am not sure how to enable JMX.

+8  A: 

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.

eljenso
+1  A: 

Look at the following simple method to connect jconsole to Websphere 6.1

It does works for me (Solaris, Was 6.1, Sun JVM), it also works with Visual VM

Enjoy !

Can you still access the WebSphere JMX beans with this solution, to get information about servlets and connection pools?
eljenso
A: 

For it It does works for me too (Redhat, was 6.1, Server JDK)

Thanks

+1  A: 

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:

  1. Add "-Djavax.management.builder.initial= -Dcom.sun.management.jmxremote" to the Generic JVM Argument.
  2. Add these lines to WebSphere/AppServer/java/jre/lib/management/management.properties
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..?

Tommy
+1 This worked perfect for me when using it for a web app.
Wayne Hartman
+2  A: 

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.

Alan Chan
+1  A: 

Hi!

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.

Boguś
Thanks, worked like a charm!
Miguel Ping
A: 

The answer from Bogus works! Thanks, but how can I use jconsole in this mode? Only the mbean tab can be used! Can you get visualvm working perhaps?

A: 

You can find the correct port to connect to on the WebSphere Application Server under Communications -> Ports. The port associated with BOOTSTRAP_ADDRESS allows you to connect.

tjg184
A: 

Thanks Bogus. Your trick worked in getting a successfull connection. But when connecting, it didn't ask for User Id and password. But it got connected anyways. But when I tried to invoke any operations in MBeans, I am getting below error, ADMN0022E: Access is denied for operationName operation on because of insufficient or empty credentials.

Any help is really apperciated. thanks.

toramanan