Kenneth Howe created GEODE-5455:
-----------------------------------

             Summary: ClassCastException in MemberMBean.showOSMetrics, 
OSMetrics is not reconstructible from CompositeData
                 Key: GEODE-5455
                 URL: https://issues.apache.org/jira/browse/GEODE-5455
             Project: Geode
          Issue Type: Bug
          Components: jmx
            Reporter: Kenneth Howe


The following code snippet throws
{code}
Exception in thread "main" java.lang.ClassCastException: 
javax.management.openmbean.CompositeDataSupport cannot be cast to 
org.apache.geode.management.OSMetrics at 
com.sun.proxy.$Proxy0.showOSMetrics(Unknown Source) 
{code}

{code:java}
  public static MBeanServerConnection getLocalMBeanServerConnectionStatic(int 
pid) {
    try {
      String address = ConnectorAddressLink.importFrom(pid);
      JMXServiceURL jmxUrl = new JMXServiceURL(address);
      return JMXConnectorFactory.connect(jmxUrl).getMBeanServerConnection();
    } catch (IOException e) {
      throw new RuntimeException(
          "Of course you still have to implement a good connection handling");
    }
  }

  public static void main(String[] args) throws IOException,
      MalformedObjectNameException, InstanceNotFoundException, 
ReflectionException {
    MBeanServerConnection mbeanServerConnection = 
getLocalMBeanServerConnectionStatic(127510);
    ObjectName mbeanName = new ObjectName("GemFire:type=Member,member=server1");
    MemberMXBean
        memberbeanInstance =
        (MemberMXBean) MBeanServerInvocationHandler
            .newProxyInstance(mbeanServerConnection, mbeanName, 
MemberMXBean.class, Boolean.TRUE);
    System.out.println(Arrays.toString(memberbeanInstance.listRegions()));
    OSMetrics cdOSMetrics = memberbeanInstance.showOSMetrics();
    //.....
  }
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to