This discussion is archived
2 Replies Latest reply: Oct 2, 2010 7:04 PM by 800140 RSS

MBean Exception after upgrading it to jre1.5.0_24

800140 Newbie
Currently Being Moderated
Hi,

I have attached the program im using to get JVM memory value,it was working perfectly in older version jre1.5.0_11.
But it stopped working after i have upgraded to new JRE version(jrockit-R28.0.1-jre1.5.0_24). Not sure it if its a bug or issue with the program.

Anyone experienced that error before?

~~~~~~~~~~~~~~~~~~~~
For reference added the connection and object return values:

javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection@1e7506:::: javax.management.remote.rmi.RMIConnector
: jmxServiceURL=service:jmx:rmi:///jndi/rmi://ukblprdlivptl03:7091/jmxrmi
com.bea:ServerRuntime=managed03,Name=managed03,Type=JRockitRuntime
~~~~~~~~~~~~~~~~~~~~

Exception in thread "Main Thread" javax.management.InstanceNotFoundException: com.bea:ServerRuntime=managed03,Name=manag
ed03,Type=JRockitRuntime
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1010)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute(DefaultMBeanServerInterceptor.java:627)
at com.sun.jmx.mbeanserver.JmxMBeanServer.getAttribute(JmxMBeanServer.java:659)
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1387)
at javax.management.remote.rmi.RMIConnectionImpl.access$100(RMIConnectionImpl.java:81)
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1247)
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1343)
at javax.management.remote.rmi.RMIConnectionImpl.getAttribute(RMIConnectionImpl.java:599)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:592)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:154)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
at java.lang.Thread.run(Thread.java:595)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)
at javax.management.remote.rmi.RMIConnectionImpl_Stub.getAttribute(Unknown Source)
at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.getAttribute(RMIConnector.java:857)
at JavaMemory.getJRockitRuntimeData(JavaMemory.java:30)
at JavaMemory.main(JavaMemory.java:63)


###########################################################################
import java.util.Hashtable;
import java.io.*;
import javax.management.MBeanServerConnection;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import javax.naming.Context;
import java.lang.management.ManagementFactory;
import javax.management.*;

public class JavaMemory
{
private static MBeanServerConnection connection;
private static JMXConnector connector;
public static void Connection(String hostname, String port) throws IOException
{
Integer portInteger = Integer.valueOf(port);
Hashtable h = new Hashtable();
JMXServiceURL address = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://"+hostname+":"+port+"/jmxrmi");
connector = JMXConnectorFactory.connect(address,null);
connection = connector.getMBeanServerConnection();
System.out.println(connection + ":::: "+ connector);
}

public static void getJRockitRuntimeData(String serverName)throws Exception
{
ObjectName jRockitRuntime=new ObjectName("com.bea:ServerRuntime="+serverName+",Name="+serverName+",Type=JRockitRuntime");
System.out.println(jRockitRuntime);

Long usedPhysicalMemory=(Long)connection.getAttribute(jRockitRuntime,"UsedPhysicalMemory");
Long freePhysicalMemory=(Long)connection.getAttribute(jRockitRuntime,"FreePhysicalMemory");
Long totalPhysicalMemory =(Long)connection.getAttribute(jRockitRuntime,"TotalPhysicalMemory");
Long totalHeap=(Long)connection.getAttribute(jRockitRuntime,"TotalHeap")/1024/1024;
Long freeHeap=(Long)connection.getAttribute(jRockitRuntime,"FreeHeap")/1024/1024;
Long usedHeap=(Long)connection.getAttribute(jRockitRuntime,"UsedHeap")/1024/1024;

System.out.println(totalHeap);
System.out.println(freeHeap);
System.out.println(usedHeap);

}

public static void takeThreadDump(String serverName) throws Exception
{
ObjectName jRockitRuntime=new ObjectName("com.bea:ServerRuntime="+serverName+",Name="+serverName+",Type=JRockitRuntime");
String dumpStack=(String)connection.getAttribute(jRockitRuntime,"ThreadStackDump");
System.out.println("\n\n\t ————–FULL THREAD_DUMP————–\n: "+dumpStack);
}

public static void main(String[] args) throws Exception
{
     
String hostname = args[0];
     String port = args[1];
     Connection(hostname, port);
     getJRockitRuntimeData(args[2]);
     //takeThreadDump(args[2]);
     connector.close();

}
}
###########################################################################

Thanks in Advance,
Rana

Edited by: user13387204 on 02-Oct-2010 11:26

Edited by: user13387204 on 02-Oct-2010 19:05

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points