2016-06-30 5 views
0

Beim Versuch, Werte von Attributen für ManagedExecutorService von Hazelcast abzurufen, erhalte ich den Fehler ReflectionException. Mit JConsole kann ich normalerweise Werte sehen.Fehler beim Abrufen des JMX-Attributwerts für Hazelcast

String connectionUrl = "service:jmx:http-remoting-jmx://127.0.0.1:9990"; 
JMXServiceURL url = new JMXServiceURL(connectionUrl); 

Map<String, Object> auth = new HashMap<>(); 
String[] credentials = new String[] {"developer", "developer"}; 
auth.put (JMXConnector.CREDENTIALS, credentials); 

JMXConnector jmxc = JMXConnectorFactory.connect(url, auth); 
MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); 
try { 
    ObjectName objectName = new ObjectName("com.hazelcast:instance=_hzInstance_1_dev,name=\"hz:async\"," 
      + "type=HazelcastInstance.ManagedExecutorService"); 
    MBeanInfo info = mbsc.getMBeanInfo(objectName); 
    mbsc.getAttribute(objectName, "eventQueueSize"); //exception here 
    //AttributeList lst = 
    // mbsc.getAttributes(objectName, new String[]{"eventQueueSize", "completedTaskCount"}); // and here 
    //System.out.println(lst); 
} finally { 
    jmxc.close(); 
} 

Ausnahme:

Exception in thread "main" javax.management.ReflectionException 
    at com.hazelcast.jmx.HazelcastMBean.getAttribute(HazelcastMBean.java:115) 
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute(DefaultMBeanServerInterceptor.java:647) 
    at com.sun.jmx.mbeanserver.JmxMBeanServer.getAttribute(JmxMBeanServer.java:678) 
    at org.jboss.as.jmx.PluggableMBeanServerImpl$TcclMBeanServer.getAttribute(PluggableMBeanServerImpl.java:1390) 
    at org.jboss.as.jmx.PluggableMBeanServerImpl.getAttribute(PluggableMBeanServerImpl.java:393) 
    at org.jboss.as.jmx.BlockingNotificationMBeanServer.getAttribute(BlockingNotificationMBeanServer.java:148) 
    at org.jboss.remotingjmx.protocol.v2.ServerProxy$GetAttributeHandler.handle(ServerProxy.java:691) 
    at org.jboss.remotingjmx.protocol.v2.ServerCommon$MessageReciever$1$1.run(ServerCommon.java:153) 
    at org.jboss.as.jmx.ServerInterceptorFactory$Interceptor$1.run(ServerInterceptorFactory.java:75) 
    at org.jboss.as.jmx.ServerInterceptorFactory$Interceptor$1.run(ServerInterceptorFactory.java:70) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at javax.security.auth.Subject.doAs(Subject.java:422) 
    at org.jboss.as.controller.AccessAuditContext.doAs(AccessAuditContext.java:94) 
    at org.jboss.as.jmx.ServerInterceptorFactory$Interceptor.handleEvent(ServerInterceptorFactory.java:70) 
    at org.jboss.remotingjmx.protocol.v2.ServerCommon$MessageReciever$1.run(ServerCommon.java:149) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: java.lang.NullPointerException 
+0

Sie sind sicher, dass der Attributname eventQueueSize und nicht EventQueueSize ist? – Nicholas

+0

@Nicholas oops, meine Schuld. Schreibe deinen Kommentar als Antwort – Rustam

Antwort

2

Ich denke, Sie sollten queueSize versuchen, wie es in der ManagedExecutorServiceMBean Klasse definiert ist:

@ManagedAnnotation("queueSize") 
@ManagedDescription("The work queue size") 
public int queueSize() { 
    return managedObject.getQueueSize(); 
} 
1

Sie sicher, dass die Attributnamen eventQueueSize und nicht EventQueueSize?

Verwandte Themen