0 Replies Latest reply on Mar 17, 2014 7:43 AM by gabrielwei

    Failed to create the cache with Infinispan5.3 + Mongodb-cache-store5.3

    gabrielwei

      I'm new to infinispan. following the docs, I tried to create cache with mongodb as cache store. but I failed programatically and declaritively. I searched the solution, but not lucky. Could pls somebody help with this?

       

      the code is:

      define cache

      private static EmbeddedCacheManager createCacheManagerProgramatically(){

              ConfigurationBuilder b = new ConfigurationBuilder();

              b.loaders().addStore(MongoDBCacheStoreConfigurationBuilder.class)

                      .host("localhost")

                      .port(27017)

                      .timeout(1500)

                      .acknowledgment(0)

                      .username("mongo")

                      .password("mongo")

                      .database("infinispan_cachestore")

                      .collection("entries")

                      .clustering().cacheMode(CacheMode.DIST_SYNC).hash().numOwners(2);

              Configuration config = b.build();

              MongoDBCacheStoreConfiguration store = (MongoDBCacheStoreConfiguration) config.loaders().cacheLoaders().get(0);

              GlobalConfiguration globalConf = GlobalConfigurationBuilder.defaultClusteredBuilder().transport()

                      .addProperty("configurationFile","jgroups.xml").build();

              EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConf);

              cacheManager.defineConfiguration("distCache", config);

              return cacheManager;

          }

       

      create cache:

      EmbeddedCacheManager cacheManager = createCacheManagerProgramatically();

              Cache<String, String> cache = cacheManager.getCache("distCache");

       

      error msg:

      Exception in thread "main" org.infinispan.CacheException: Unable to invoke method public void org.infinispan.loaders.CacheLoaderManagerImpl.start() on object of type CacheLoaderManagerImpl

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

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

        at org.infinispan.factories.AbstractComponentRegistry.invokeStartMethods(AbstractComponentRegistry.java:658)

        at org.infinispan.factories.AbstractComponentRegistry.internalStart(AbstractComponentRegistry.java:647)

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

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

        at org.infinispan.CacheImpl.start(CacheImpl.java:691)

        at org.infinispan.manager.DefaultCacheManager.wireAndStartCache(DefaultCacheManager.java:685)

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

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

        at org.haowei.clusteredcache.distribution.expMongodb.main(expMongodb.java:24)

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

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        at java.lang.reflect.Method.invoke(Method.java:606)

        at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

      Caused by: org.infinispan.CacheException: Unable to start cache loaders

        at org.infinispan.loaders.CacheLoaderManagerImpl.start(CacheLoaderManagerImpl.java:163)

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

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        at java.lang.reflect.Method.invoke(Method.java:606)

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

        ... 15 more

      Caused by: java.lang.IllegalArgumentException: Cannot load null class!

        at org.infinispan.util.Util.getInstance(Util.java:224)

        at org.infinispan.loaders.CacheLoaderManagerImpl.createCacheLoader(CacheLoaderManagerImpl.java:346)

        at org.infinispan.loaders.CacheLoaderManagerImpl.createCacheLoader(CacheLoaderManagerImpl.java:336)

        at org.infinispan.loaders.CacheLoaderManagerImpl.start(CacheLoaderManagerImpl.java:149)

        ... 20 more