2 Replies Latest reply on Mar 20, 2012 7:27 AM by sudheesh p

    Null Pointer exception while performing "resetStatistics" in Infinispan 5.1.2

    sudheesh p Newbie

      Hi,

       

       

      I use the following snippet in order to invoke the StatisticsMBean and its operation resetStatistics.

       

       

      MBeanServerConnection mBeanServer = ManagementFactory

                                                        .getPlatformMBeanServer();

       

       

                                    String jmxQuery = "org.infinispan:type=Cache,name=" + "\""

                                                        + cache.getName() + "(" + (cache.getCacheConfiguration().clustering().cacheModeString()).toLowerCase() + ")" + "\""

                                                        + ",manager=" + "\"" + "DefaultCacheManager" + "\""

                                                        + ",component=Statistics";

       

                                    Set<ObjectInstance> queryResults;

                                    Object result = null;

       

       

                                    try {

                                              queryResults = mBeanServer.queryMBeans(new ObjectName(jmxQuery),

                                                                  null);

       

       

                                              for (ObjectInstance objectInstance : queryResults) {

                                                        ObjectName objectName = objectInstance.getObjectName();

                                                        result = mBeanServer.invoke(objectName, "resetStatistics",

                                                                            null, null);

       

       

                                              }

       

       

                                    } catch (Exception e) {

                                              throw new RuntimeException(e.getMessage(), e);

       

       

                                    }

       

       

      However i get the following error when i execute this snippet:

       

       

      5838 [main] DEBUG org.infinispan.jmx.ResourceDMBean  - Invoke method called on resetStatistics

      Exception in thread "main" java.lang.RuntimeException

                at com.hp.ispan.jmx.test.MyTest.main(MyTest.java:81)

      Caused by: javax.management.MBeanException

                at org.infinispan.jmx.ResourceDMBean.invoke(ResourceDMBean.java:266)

                at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(Unknown Source)

                at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(Unknown Source)

                at com.hp.ispan.jmx.test.MyTest.main(MyTest.java:75)

      Caused by: java.lang.NullPointerException

                at org.infinispan.jmx.ResourceDMBean.invoke(ResourceDMBean.java:259)

                ... 3 more

       

       

       

       

      I am using the distribution clustering mode.

       

      Pls help me to resolve this.

       

      Regards

      Sudheesh