How do you enable JMX in Websphere?
Solution 1
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.
Solution 2
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
Solution 3
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.
Solution 4
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:
- Add "-Djavax.management.builder.initial= -Dcom.sun.management.jmxremote" to the Generic JVM Argument.
- 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..?
Solution 5
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.
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Admin
Updated on July 22, 2020Comments
-
Admin almost 4 years
I would like to use JConsole to monitor my Websphere application, but I am not sure how to enable JMX.
-
Andre Steingress about 13 years+1 worked like a charm. I am sorry for the pain you must have gone through :)
-
jambriz over 12 yearsthis sort of worked for me, i had to add these same parameters in the websphere console under
Servers/Application servers/server1/Java y gestión de procesos/Definición de proceso/Máquina virtual Java/Argumentos de JVM genéricos
(sorry this is in spanish, i prefer the english version too, but someone at ibm must ve thought we native spanish speakers would prefer a godawful translation). hope this helps someone anyway -
djangofan about 12 yearsActually, this doesn't work. I tried it by adding those params to the D_ARGS option in the startServer.sh file . Then, connected on 1099 and it only shows data for the websphere admin process and does not show information for the contained application process.
-
djangofan over 11 yearsMakes sense that it wouldn't work because WebSphere runs on a IBM JDK and therefore packages in com.sun.* don't exist, right?
-
Chris about 11 years@Tommy - did you get the "interesting" stuff somehow? I mean without the whole extra jars/IIOP mumbo-jumbo...
-
Tommy almost 11 years@Chris No, never got it to work like I wanted. Ended up using the PMI servlet that comes with WAS then parsing the xml and graphing it with Munin. Works fine
-
Samih A over 10 yearsworked for me ... please note that after -Djavax.management.builder.initial= add SPACE
-
poussma over 10 years+1 for the "good luck, you'll need it"... BTW, I have the tree with the object but I can't see the properties because of ADMN0022E (missing rights or something like that) Any idea ?
-
Flavio about 10 yearsYou might have to add
jconsole.jar
to the classpath also with the IBM jconsole. -
Joost almost 9 yearsThe 'magic URL'
service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
worked for me -
Berlin Brown over 7 yearsI did all of this, still didn't work. I got the MBeans tab but not the memory.