5 Replies Latest reply on Feb 4, 2011 10:03 AM by galder.zamarreno

    Exceptions on calling stop on cache and cache manager

    sudheerk84

      I am getting the following errors when i try to stop the cache and teh cachermanager. Could anyone help me in with what am i doing wrong here ?

       

       

      Caused by: java.lang.NullPointerException

          at org.infinispan.manager.DefaultCacheManager.removeListener(DefaultCacheManager.java:567)

       

      I am not adding any cache listeners to teh cache.

       

      I use spring to instantiate my beans as foolows

       

      <bean id="cacheManager" class="com.mycompany.cache.infinispan.CacheManager" init-method="init" destroy-method="destroy">

               <constructor-arg name="fileName" value="classpath:test-config.xml"/>

               <property name="transactionManager" ref="atomikosTransactionManager"/>

      </bean>

       

      destroy method calls - cacheManager.stop();(org.infinispan.manager.DefaultCacheManager)

       

      <bean id="accountCache" class="com.mycompany.cache.infinispan.InfinispanImpl" destroy-method="shutdown" >

             <constructor-arg name="cacheManager" ref="cacheManager"/>

             <constructor-arg name="name" value="accountCache"/>

        </bean>

       

      destroy methods calls -  cache.stop(); (org.infinispan.Cache)

       

      Cache configuratiosn are as follows

       

        <namedCache name="accountCache">

              <clustering mode="distribution">

                  <sync />

                  <hash numOwners="2" rehashWait="120000" rehashRpcTimeout="600000" />

              </clustering>

          </namedCache>

       

       

      org.springframework.beans.factory.support.DisposableBeanAdapter.invokeCustomDestroyMethod:280  - Invocation of destroy method 'destroy' failed on bean with name 'cacheManager'

      org.infinispan.CacheException: Unable to invoke method private void org.infinispan.transaction.xa.TransactionTable.stop() on object

          at org.infinispan.util.ReflectionUtil.invokeAccessibly(ReflectionUtil.java:174)

          at org.infinispan.factories.AbstractComponentRegistry$PrioritizedMethod.invoke(AbstractComponentRegistry.java:889)

          at org.infinispan.factories.AbstractComponentRegistry.internalStop(AbstractComponentRegistry.java:716)

          at org.infinispan.factories.AbstractComponentRegistry.stop(AbstractComponentRegistry.java:610)

          at org.infinispan.factories.ComponentRegistry.stop(ComponentRegistry.java:168)

          at org.infinispan.CacheDelegate.stop(CacheDelegate.java:325)

          at org.infinispan.manager.DefaultCacheManager.stop(DefaultCacheManager.java:537)

          at com.mycompany.cache.infinispan.CacheManager.destroy(CacheManager.java:79)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

          at java.lang.reflect.Method.invoke(Unknown Source)

          at org.springframework.beans.factory.support.DisposableBeanAdapter.invokeCustomDestroyMethod(DisposableBeanAdapter.java:273)

          at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:199)

          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:487)

          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:463)

          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:431)

          at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1048)

          at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1022)

          at org.springframework.context.support.AbstractApplicationContext$3.run(AbstractApplicationContext.java:940)

      Caused by: java.lang.reflect.InvocationTargetException

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

          at java.lang.reflect.Method.invoke(Unknown Source)

          at org.infinispan.util.ReflectionUtil.invokeAccessibly(ReflectionUtil.java:171)

          ... 19 more

       

       

       

      Caused by: java.lang.NullPointerException

          at org.infinispan.manager.DefaultCacheManager.removeListener(DefaultCacheManager.java:567)

       

       

       

          at org.infinispan.transaction.xa.TransactionTable.stop(TransactionTable.java:86)

          ... 24 more

        • 1. Exceptions on calling stop on cache and cache manager
          sudheerk84

          I just did a bit of reading and i found teh following in cache manager API.

           

          1. http://docs.jboss.org/infinispan/4.0/apidocs/org/infinispan/manager/CacheManager.html

           

          When the system shuts down, it should call Lifecycle.stop() on the CacheManager.  This will ensure all caches within its scope are properly stopped as well.

          NB: Shared caches are supported (and in fact encouraged) but if they are used it's the users responsibility to ensure that at least one but only one caller calls stop() on the cache, and it does so with the awareness that others may be using the cache.

           

          2. When i see in release 4.2 it says

           

          http://docs.jboss.org/infinispan/4.2/apidocs/org/infinispan/manager/EmbeddedCacheManager.html

           

          Lifecycle - EmbeddedCacheManagers have a lifecycle (it implements Lifecycle) and the default constructors also call Lifecycle.start().  Overloaded versions of the constructors are available, that do not start the CacheManager, although it must be kept in mind that CacheManagers need to be started before they can be used to create Cache instances.

           

           

          Since i am using version 4.2 Do i need to explicitly call cachemanager.stop() {which internally calls cache.stop()}  ?

           

          And when i am using distributed cache , what is teh impact of calling cacheManager.stop on a distributed cache.Does it delete all teh entries in numNodes(when i use dist mode) ?

          • 2. Exceptions on calling stop on cache and cache manager
            sudheerk84

            I think a Bug is already filed for this exception.

             

             

            https://issues.jboss.org/browse/ISPN-779

            • 3. Exceptions on calling stop on cache and cache manager
              pelverum

              Does anyone know if this issue is resolved in either the 4.2.0-Final release or the current 4.2.1-* release cycle?  I am seeing this NPE when running Infinispan as Hibernate L2 cache when executing my unit tests.  It really isn't causing a problem at the moment, but it would be nice to understand if there is a fix in the 4.2 code stream.

              • 4. Exceptions on calling stop on cache and cache manager
                sudheerk84

                I am getting this exception even when i am using 4.2 final.

                 

                The jira ticket mentioned above shows that fix version as 
                5.0.0 ALPHA1
                                                                            

                • 5. Exceptions on calling stop on cache and cache manager
                  galder.zamarreno

                  That particular issue only affected 5.x hence why it was not fixed in 4.x. Hint: the last comment in the jira explains it

                   

                  Wrt your issue, no idea what the root cause is right now, would you mind attaching or providing us with a test case to replicate it?

                  1 of 1 people found this helpful