2 Replies Latest reply on Feb 6, 2015 2:03 PM by Andrew Schmidt

    Infinispan cache with joda DateTime

    Andrew Schmidt Newbie

      I've been trying to use Wildfly 8.2.0 + infinispan Cache<> + filestore with a joda date time as the value and am experiencing serialization failures:

       

      standalone-full.xml:

       

        <cache-container name="test-container">
                <local-cache name="test">
                    <file-store passivation="true" purge="true"/>
                </local-cache>
         </cache-container>
      
      

       

       

      (i set purge to = true so that I can test this)

       

      TestCache.java:

       

      @Singleton
      @Startup
      public class TestCache
      {
          @Resource( lookup = "java:jboss/infinispan/cache/test-container/test" )
          private Cache<String, DateTime> cache;
      
          @PostConstruct
          public void test()  {
              cache.put( "test", new DateTime() );
              System.out.println( "test run" );
          }
      }
      
      

       

      jboss-deployment:

       

      <jboss-deployment-structure>
          <deployment>
              <dependencies>
                  <module name="org.infinispan" />
                  <module name="org.infinispan.commons" />
              </dependencies>
          </deployment>
      </jboss-deployment-structure>
      
      

       

      Server boots up fine and the cache entry is put into the cache.   When deployment is stopped the following exception occurs when shutting down the cache:

       

      at org.infinispan.commons.util.ReflectionUtil.invokeAccessibly(ReflectionUtil.java:185)
      at org.infinispan.factories.AbstractComponentRegistry$PrioritizedMethod.invoke(AbstractComponentRegistry.java:869)
      at org.infinispan.factories.AbstractComponentRegistry.internalStop(AbstractComponentRegistry.java:674)
      at org.infinispan.factories.AbstractComponentRegistry.stop(AbstractComponentRegistry.java:552)
      at org.infinispan.factories.ComponentRegistry.stop(ComponentRegistry.java:241)
      at org.infinispan.CacheImpl.stop(CacheImpl.java:697)
      at org.infinispan.CacheImpl.stop(CacheImpl.java:692)
      at org.infinispan.AbstractDelegatingCache.stop(AbstractDelegatingCache.java:316)
      at org.jboss.as.clustering.infinispan.subsystem.CacheService.stop(CacheService.java:96)
      at org.jboss.as.clustering.msc.AsynchronousService$2.run(AsynchronousService.java:114) [wildfly-clustering-common-8.2.0.Final.jar:8.2.0.Final]
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_75]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_75]
      at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_75]
      at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.1.Final.jar:2.1.1.Final]

      Caused by: java.lang.NoClassDefFoundError: org/joda/time/LocalTime

      at java.lang.Class.getDeclaredMethods0(Native Method) [rt.jar:1.7.0_75]
      at java.lang.Class.privateGetDeclaredMethods(Class.java:2615) [rt.jar:1.7.0_75]
      at java.lang.Class.getDeclaredMethods(Class.java:1860) [rt.jar:1.7.0_75]
      at org.jboss.marshalling.reflect.SerializableClass.<init>(SerializableClass.java:80) [jboss-marshalling-1.4.9.Final.jar:1.4.9.Final]
      at org.jboss.marshalling.reflect.SerializableClassRegistry.lookup(SerializableClassRegistry.java:90) [jboss-marshalling-1.4.9.Final.jar:1.4.9.Final]
      at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:177)
      at org.jboss.marshalling.AbstractObjectOutput.writeObject(AbstractObjectOutput.java:58) [jboss-marshalling-1.4.9.Final.jar:1.4.9.Final]
      at org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:111) [jboss-marshalling-1.4.9.Final.jar:1.4.9.Final]
      at org.infinispan.commons.marshall.jboss.AbstractJBossMarshaller.objectToObjectStream(AbstractJBossMarshaller.java:74)
      at org.infinispan.marshall.core.VersionAwareMarshaller.objectToBuffer(VersionAwareMarshaller.java:77)
      at org.infinispan.commons.marshall.AbstractMarshaller.objectToBuffer(AbstractMarshaller.java:41)
      at org.infinispan.commons.marshall.AbstractDelegatingMarshaller.objectToBuffer(AbstractDelegatingMarshaller.java:85)
      at org.infinispan.marshall.core.MarshalledEntryImpl.marshall(MarshalledEntryImpl.java:105)
      at org.infinispan.marshall.core.MarshalledEntryImpl.getValueBytes(MarshalledEntryImpl.java:88)
      at org.infinispan.persistence.file.SingleFileStore.write(SingleFileStore.java:275)
      at org.infinispan.persistence.manager.PersistenceManagerImpl.writeToAllStores(PersistenceManagerImpl.java:457)
      at org.infinispan.eviction.PassivationManagerImpl.passivateAll(PassivationManagerImpl.java:94)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_75]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_75]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_75]
      at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_75]
      at org.infinispan.commons.util.ReflectionUtil.invokeAccessibly(ReflectionUtil.java:183)
      ... 13 more

      Caused by: java.lang.ClassNotFoundException: org.joda.time.LocalTime from [Module "deployment.test-infinispan2.war:main" from Service Module Loader]

      at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final]
      at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final]
      at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final]
      at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final]
      at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final]
      ... 35 more

       

      Anyone experienced this problem?  or know what I'm doing wrong?

        • 1. Re: Infinispan cache with joda DateTime
          Paul Ferraro Master

          You appear to have the joda library bundled with your deployment.  The problem with this is that your deployment, as a module, no longer exists when Infinispan attempts to passivate your cache entries to disk on undeploy.  You shouldn't have this problem with purge enabled.  Enabling purge should cause Infinispan to clear your cache and cache store, rather than passivating existing entries to the cache store.  You can prevent this issue by not bundling the joda library with your deployment. Instead export WildFly's joda-time module to your application.  This way, Infinispan will be able to resolve the joda time classes when your deployment is not longer active.

           

          <jboss-deployment-structure> 
              <deployment> 
                  <dependencies> 
                      <module name="org.infinispan"/> 
                      <module name="org.infinispan.commons"/> 
                      <module name="org.joda.time"/>
                  </dependencies> 
              </deployment> 
          </jboss-deployment-structure> 
          
          
          • 2. Re: Re: Infinispan cache with joda DateTime
            Andrew Schmidt Newbie

            Thanks that did solve the problem.

             

            You shouldn't have this problem with purge enabled.

            While testing,  purge only cleaned out the cache when the deployment started.   When stopping deployment I always saw the cache passivating the entries to disk.