0 Replies Latest reply on May 15, 2013 7:46 AM by Christoph Ortmann

    How to create a named cache with Infinispan 4.2.1.FINAL on JBoss 5.1

    Christoph Ortmann Newbie

      First: Hello community (I think this is my first post :-)

       

      I am running a single .ear file on a JBoss 5.1.0.GA server (64bit on SUN SOLARIS), not clustered.  I want to use Infinispan as a global cache (_NOT_ a second level cache for hibernate, NOT (yet) distributed).I included Infinispan 4.2.1.FINAL in my pom.xml, it deployed and I was able to create and use the default cache.

       

      But now I want to create a named cache as follows:

               

              try {

                  final String configFile = "infinispan_config.xml";

                  DefaultCacheManager cacheManager = new DefaultCacheManager(configFile);

                  Configuration config = cacheManager.getDefaultConfiguration().clone();

                  config.setEvictionStrategy(EvictionStrategy.NONE); // "to disable eviction"

                  config.setEvictionMaxEntries(-1); // "-1 means no limit"

                  config.setExpirationLifespan(-1); // "-1 means the entries never expire"

                  String newCacheName = "MyCache_" + myId;

                  cacheManager.defineConfiguration(newCacheName, config);

                  cache = cacheManager.getCache(newCacheName);

              } catch (IOException ex) {

                  logger.error("Cannot reading file: " + configFile);

              }

       

      Unfortunately this leads to the following stacktrace:

       

      Unable to invoke method public void org.infinispan.marshall.VersionAwareMarshaller.start() on object

      org.infinispan.CacheException: Unable to invoke method public void org.infinispan.marshall.VersionAwareMarshaller.start() 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.internalStart(AbstractComponentRegistry.java:687)

              at org.infinispan.factories.AbstractComponentRegistry.start(AbstractComponentRegistry.java:589)

              at org.infinispan.factories.GlobalComponentRegistry.start(GlobalComponentRegistry.java:137)

              at org.infinispan.factories.ComponentRegistry.start(ComponentRegistry.java:137)

              at org.infinispan.CacheDelegate.start(CacheDelegate.java:323)

              at org.infinispan.manager.DefaultCacheManager.createCache(DefaultCacheManager.java:516)

              at org.infinispan.manager.DefaultCacheManager.getCache(DefaultCacheManager.java:439)

       

      Oh, Btw:

      the "infinispan_config.xml" file simply contains a <infinispan></infinispan> entry. I cannot use a static file as I want to give the cache a "dynamic" myId (int) as name suffix.

       

       

      Can anybody help me this? Is it really soooo complicated to create the cache? What is the difference in creating a named cache vs using the default cache.

       

       

      PS:

      I looked around and found _LOTS_ of posts, but I am confused wether JBoss 5.1.0.GA and Infinispan 4.2.1.FINAL will properly work together, esp. as I was able to put something to the default cache and get it back later.

       

      PPS:

      java version is "1.6.0_26":Java(TM) SE Runtime Environment (build 1.6.0_26-b03), Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)