NullPointerException in "message-counter" example code?
stevehunt Sep 1, 2011 1:32 PMHi,
Trying out hornetq for the first time, but having problems pulling out the message counters, getting a java.lang.reflect.InvocationTargetException stemming from an NPE at
org.hornetq.core.messagecounter.MessageCounter.getMessageCount(MessageCounter.java:205)
when trying to run the message-counter example code against an already existing queue (evaluating a switch from ActiveMQ, and working off the example code to get what we'd need).
My environment is
HornetQ 2.2.5-FINAL
Ubuntu 10.4 LTS
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Easiest way to replicate this is to run the message-counter example twice - works fine the first time, but the second time it reports the following
[java] Sleep a little bit to have the queue sampled...
[java] java.lang.IllegalStateException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
[java] at org.hornetq.jms.management.impl.JMSQueueControlImpl.listMessageCounter(JMSQueueControlImpl.java:330)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:597)
[java] at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:93)
[java] at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:27)
[java] at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:208)
[java] at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:120)
[java] at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:262)
[java] at javax.management.StandardMBean.invoke(StandardMBean.java:391)
[java] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
[java] at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
[java] at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1427)
[java] at javax.management.remote.rmi.RMIConnectionImpl.access$200(RMIConnectionImpl.java:72)
[java] at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1265)
[java] at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1360)
[java] at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:788)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:597)
[java] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)
[java] at sun.rmi.transport.Transport$1.run(Transport.java:159)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
[java] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
[java] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
[java] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
[java] at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
[java] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
[java] at java.lang.Thread.run(Thread.java:662)
[java] Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
[java] at org.hornetq.utils.json.JSONObject.populateInternalMap(JSONObject.java:406)
[java] at org.hornetq.utils.json.JSONObject.<init>(JSONObject.java:304)
[java] at org.hornetq.api.core.management.MessageCounterInfo.toJSon(MessageCounterInfo.java:61)
[java] at org.hornetq.jms.management.impl.JMSQueueControlImpl.listMessageCounter(JMSQueueControlImpl.java:326)
[java] ... 31 more
[java] Caused by: java.lang.reflect.InvocationTargetException
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:597)
[java] at org.hornetq.utils.json.JSONObject.populateInternalMap(JSONObject.java:368)
[java] ... 34 more
[java] Caused by: java.lang.NullPointerException
[java] at org.hornetq.core.messagecounter.MessageCounter.getMessageCount(MessageCounter.java:205)
[java] ... 39 more
[java]
[java] #####################
[java] ### FAILURE! ###
[java] #####################
[java] Java Result: 1
If I delete the queue's data directory the example runs fine again (but don't want to have to do that in production).
I've also tried
* setting message-counter-sample-period down to 10ms, in case it was a problem with the counter not having sampled
* placing the message counter initialisation code after the consume, in case it needed a dequeue to update the value
but both had exactly the same issue.
Any ideas?
Thanks!
Steve
ps. I'd be happy with any workaround or alternate method for sampling these values if there are any (loving the aio persistence!)