WAS 6.1, JMX & the AdminClient
I’ve recently had the need to connect to the WAS 6.1 JMX. Easy I thought …. with the wealth of documentation etc, this was going to be a 5 minute job with lots of time left over to play. How wrong I was. How very wrong.
As with all my experiences with WAS, this proved to be a lot harder than I initially thought (and with the amount I have worked with this app server, I really should know by now and should definitely be better at it, but hey-ho… ). What follows is how I managed to connect to a WAS server, running with custom SSL certificates (i.e. not from a well known commercial Certification Authority, but using keytool) over SOAP. As with anything you find on the web/blogsphere - YMMV.
Certificates
First things first: you’ll need to get the certificate into your keystore. For this, you can use the handy-dandy tool from Andreas Sterbenz: http://blogs.sun.com/andreas/entry/no_more_unable_to_find. Download this to something like c:\dev\tools, compile it and run it;
java InstallCert <your-server>
What you’ll end up with is a file called jssecacerts in the directory you ran the app in.
Libraries
Now, having obtained this, you’re pretty set to go - all you need now are the required libraries, which are;
-
org.eclipse.osgi_3.1.2.jar [located in <WAS_HOME/plugins>] -
ws_runtime.jar -
com.ibm.ws.webservices.thinclient_6.1.0.jar
Plus any other libs etc needed for you app.
Run like the wind
Having got all your magic pieces together, it should be possible to connect. Below is an example of a small Main program which just connects and gets a list of all JMX beans. Nowt fancy, but it should be enough to get you going. I ran this on Windows XP SP2 using an IBM JVM:
> java -version
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build pwi32dev-20060511 (SR2))
IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 Windows XP x86-32 j9vmwi3223-20060504 (JIT enabled)
J9VM - 20060501_06428_lHdSMR
JIT - 20060428_1800_r8
GC - 20060501_AA)
JCL - 20060511a
The application:
1 import java.security.Security; 2 import java.util.Arrays; 3 import java.util.Iterator; 4 import java.util.Properties; 5 import java.util.Set; 6 7 import javax.management.MBeanAttributeInfo; 8 import javax.management.MBeanInfo; 9 import javax.management.MBeanNotificationInfo; 10 import javax.management.MBeanOperationInfo; 11 import javax.management.MBeanParameterInfo; 12 import javax.management.ObjectName;import com.ibm.websphere.management.AdminClient; 13 import com.ibm.websphere.management.AdminClientFactory; 14 15 public class Main { 16 17 18 public static void main(String[] args) { 19 Properties connectProps = new Properties(); 20 System.out.println(Main.class.getClassLoader().toString()); 21 22 // Set to the downloaded/installed truststore 23 System.setProperty("javax.net.ssl.trustStore", "C:\\dev\\java\\IBMJDK1.5.0_00\\certtools\\jssecacerts"); 24 25 // Security provider - required 26 Security.setProperty("ssl.SocketFactory.provider", "com.ibm.jsse2.SSLSocketFactoryImpl"); 27 Security.setProperty("ssl.ServerSocketFactory.provider", "com.ibm.jsse2.SSLServerSocketFactoryImpl"); 28 29 // Properties for connection 30 connectProps.setProperty(AdminClient.CONNECTOR_HOST, "your.host.com"); 31 connectProps.setProperty(AdminClient.CONNECTOR_PORT, "8880"); 32 connectProps.setProperty(AdminClient.CONNECTOR_TYPE, AdminClient.CONNECTOR_TYPE_SOAP); 33 connectProps.setProperty(AdminClient.CONNECTOR_SECURITY_ENABLED, "true"); 34 connectProps.setProperty(AdminClient.USERNAME, "sysadmin"); 35 connectProps.setProperty(AdminClient.PASSWORD, "sysadmin"); 36 37 AdminClient adminClient = null; 38 try { 39 adminClient = AdminClientFactory.createAdminClient(connectProps); 40 System.out.println(adminClient.getMBeanCount()); 41 } catch (Exception e) { 42 System.out.println("Exception creating admin client: " + e); 43 e.printStackTrace(System.err); 44 45 } 46 } 47 } 48 49
Anyway - I hope that helps someone. Please don’t ask if I know how to sort out your problem as I most likely don’t. Also, if you post asking me to email you the answer, just know that I will chuckle to myself and won’t.
Happy hunting!
Search
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Aug | ||||||
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |