Using Websphere(WAS) API in Java class to get WAS server details

Using Websphere(WAS) API in Java class to get WAS server details

Here is a simple Java class which WAS(Websphere) API's to get WAS(Websphere) server details like cellname and nodename etc.

To make the below java class work we need to Jar files to be added to build path in our eclipse . These jar files will be available in WAS 851 installaiton.

C:\Program Files\IBM\WebSphere\AppServer\runtimes\com.ibm.ws.admin.client_8.5.0.jar

C:\Program Files\IBM\WebSphere\AppServer\plugins\com.ibm.ws.security.crypto.jar

Java class: 

package com.ibm.was.api.test;

import java.util.Iterator;

import java.util.Set;

import javax.management.ObjectName;

import com.ibm.websphere.management.AdminClient;

import com.ibm.websphere.management.AdminClientFactory;

public class AdminClientTest {

public static void main(String[] args) {

AdminClient ac = null;

java.util.Properties props = new java.util.Properties();

props.put(AdminClient.CONNECTOR_TYPE, AdminClient.CONNECTOR_TYPE_SOAP);

props.put(AdminClient.CONNECTOR_HOST, "localhost");

//16313 : bootstrap port , check corresposding port from ur Aboutheprofile.txt

props.put(AdminClient.CONNECTOR_PORT, "16313");

props.setProperty(AdminClient.CONNECTOR_SECURITY_ENABLED, "true");

props.setProperty(AdminClient.USERNAME, "UR_PROFILE_USERNAME");

props.setProperty(AdminClient.PASSWORD, "UR_PROFILE_PASSWORD");

// Trust store properties

props.setProperty("javax.net.ssl.trustStore","C:\\Program Files\\IBM\\JazzSM\\profile\\etc\\DummyClientTrustFile.jks");

//WebAS : this is a default password to be used . Don't change this

props.setProperty("javax.net.ssl.trustStorePassword","WebAS");

// Key store props

props.setProperty("javax.net.ssl.keyStore", "C:\\Program Files\\IBM\\JazzSM\\profile\\etc\\DummyClientKeyFile.jks");

//WebAS : this is a default password to be used . Don't change this

props.setProperty("javax.net.ssl.keyStorePassword", "WebAS");

try {

ac = AdminClientFactory.createAdminClient(props);

System.out.println ("connected");

javax.management.ObjectName on = new ObjectName("WebSphere:type=Server,*");

Set servers = ac.queryNames(on, null);

Iterator itr = servers.iterator();

while(itr.hasNext()){

System.out.println(itr.next().toString());

}

}

catch(Exception ex) {

System.out.println("getAdminClient: exception");

ex.printStackTrace();

}

}

}

Sample Output : 

connected

 

WebSphere:name=server1,process=server1,platform=proxy,node=JazzSMNode01,j2eeType=J2EEServer,version=8.5.0.1,type=Server,mbeanIdentifier=cells/JazzSMNode01Cell/nodes/JazzSMNode01/servers/server1/server.xml#Server_1183122130078,cell=JazzSMNode01Cell,spec=1.0,processType=UnManagedProcess

 

Reference : WAS 6.1 JMX AdminClient. (Websphere forum at JavaRanch)

http://pic.dhe.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=%2Fcom.ibm.websphere.express.doc%2Finfo%2Fexp%2Fae%2Frprf_samplecodeapidirect.html

http://pic.dhe.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=%2Fcom.ibm.websphere.express.doc%2Finfo%2Fexp%2Fae%2Frjmx_adminclient.html

http://pic.dhe.ibm.com/infocenter/wasinfo/v8r0/index.jsp?topic=%2Fcom.ibm.websphere.express.doc%2Finfo%2Fexp%2Fae%2Ftxml_adminclient.html

http://pic.dhe.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=%2Fcom.ibm.websphere.express.doc%2Finfo%2Fexp%2Fae%2Frjmx_adminclient.html


0 comments to "Using Websphere(WAS) API in Java class to get WAS server details"

Post a comment

Whoever writes Inappropriate/Vulgar comments to context, generally want to be anonymous …So I hope U r not the one like that?
For lazy logs, u can at least use Name/URL option which doesn’t even require any sign-in, The good thing is that it can accept your lovely nick name also and the URL is not mandatory too.
Thanks for your patience
~Krishna(I love "Transparency")

Popular Posts

Enter your email address:

Buffs ...

Tags


Powered by WidgetsForFree