unable to get JVMStats

I am running a stand-alone Java client code using JMX on Websphere App Server 6.0.2. It returns me null value for JVMStats object. The code is as follows. Please let me know what could be the problem.

Thanks,

Vishal

***********************************************************************

import java.rmi.RemoteException;

import java.util.Properties;

import java.util.Set;

import javax.ejb.CreateException;

import javax.management.AttributeNotFoundException;

import javax.management.InstanceNotFoundException;

import javax.management.MBeanException;

import javax.management.MalformedObjectNameException;

import javax.management.ObjectName;

import javax.management.ReflectionException;

import javax.rmi.PortableRemoteObject;

import javax.management.j2ee.Management;

import javax.management.j2ee.ManagementHome;

import javax.management.j2ee.statistics.JVMStats;

import javax.naming.Context;

import javax.naming.InitialContext;

import javax.naming.NamingException;

/**

* @author vopatel

*/

public class JVMEjbAdmin{

private ObjectName jvm;

Management mejb = null;

public static void main(String[] args) {

JVMEjbAdmin ace = new JVMEjbAdmin();

// Create an AdminClient

ace.createAdminClient();

// Find a NodeAgent MBean

ace.getJVMMBean();

}

private void createAdminClient() {

Properties props = new Properties();

props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");

props.setProperty(Context.PROVIDER_URL, "iiop://localhost:2809");

Context ic = null;

try {

ic = new InitialContext(props);

} catch (NamingException e) {

e.printStackTrace();

}

Object obj = null;

try {

obj = ic.lookup("ejb/mgmt/MEJB");

System.out.println(" name = " + obj.getClass().getName());

System.out.println("obj = " + obj);

} catch (NamingException e1) {

e1.printStackTrace();

}

ManagementHome mejbHome = (ManagementHome)

PortableRemoteObject.narrow(obj, ManagementHome.class);

try {

mejb = mejbHome.create();

} catch (RemoteException e2) {

e2.printStackTrace();

} catch (CreateException e2) {

e2.printStackTrace();

}

System.out.println("Connected to DeploymentManager");

}

private void getJVMMBean() {

ObjectName jvmQuery = null;

try {

jvmQuery = new ObjectName("*:j2eeType=JVM,*");

} catch (MalformedObjectNameException e) {

e.printStackTrace();

}

Set s = null;

try {

s = mejb.queryNames(jvmQuery, null);

ObjectName jvmMBean = (ObjectName) s.iterator().next();

JVMStats stats = (JVMStats) mejb.getAttribute(jvmMBean,"stats");

System.out.println(" stats = " + stats);

//String[] statisticNames = stats.getStatisticNames();

} catch (AttributeNotFoundException e2) {

e2.printStackTrace();

} catch (InstanceNotFoundException e2) {

e2.printStackTrace();

} catch (MBeanException e2) {

e2.printStackTrace();

} catch (ReflectionException e2) {

e2.printStackTrace();

} catch (RemoteException e2) {

e2.printStackTrace();

}

}

}

****************************************************************

[3451 byte] By [vopatela] at [2007-10-3 3:59:03]
# 1

Hi Vishal,

This looks more like a question for Websphere gurus.

You may want to ask it on the JMX-FORUM where some users may already

have experience with Websphere - or better, try to locate a Websphere

dedicated forum...

See:

http://blogs.sun.com/jmxetc/entry/where_can_i_get_my

for more info on the JMX-FORUM...

-- daniel

JMX, SNMP, Java, etc...

http://blogs.sun.com/jmxetc

dfuchsa at 2007-7-14 21:57:44 > top of Java-index,Core,Monitoring & Management...
# 2

Hi,

I am not J2EE expert but, i suggest one way to know exact syntax of ObjectName. Try with, null parameter in queryName method of remote management interface. And the print all the object u retrived. If u able to list object name which one u trying to get then use that object in queryName method again. This may be a ObjectName object creation problem.

Hope, this wil be useful to u.

vinodpatel2006a at 2007-7-14 21:57:44 > top of Java-index,Core,Monitoring & Management...