4 Replies Latest reply on Aug 20, 2009 7:01 AM by Manik Surtani

    Null pointer setting the FileCacheStore via xml

    David Pleydell Newbie

      Hi,

      I was trying to configure the FileCacheStore via the config file as per the tutorials.

      If I comment out the cache store in the xml and try and load the config I get the following error:

      Exception in thread "main" org.infinispan.config.ConfigurationException: java.lang.NullPointerException
       at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:212)
       at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:196)
       at au.com.reece.infinispan.infinispan_test1.InfiniSpanApp.main(InfiniSpanApp.java:46)
      Caused by: java.lang.NullPointerException
       at org.infinispan.config.InfinispanConfiguration.parseNamedConfigurations(InfinispanConfiguration.java:228)
       at org.infinispan.manager.DefaultCacheManager.initialize(DefaultCacheManager.java:251)
       at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:209)
      


      The config file is:
      <?xml version="1.0" encoding="UTF-8"?>
      
      <infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:infinispan:config:4.0">
       <global>
       <transport clusterName="demoCluster"/>
       </global>
      
       <default>
       <clustering mode="replication">
       </clustering>
       </default>
      
      <!-- <namedCache name="CacheStore">-->
      <!-- <loaders passivation="false" shared="false" preload="true">-->
      <!-- <loader class="org.infinispan.loaders.file.FileCacheStore" fetchPersistentState="false"-->
      <!-- ignoreModifications="false" purgeOnStartup="false">-->
      <!-- <properties>-->
      <!-- <property name="location" value="/temp/cacheStore"/>-->
      <!-- </properties>-->
      <!-- </loader>-->
      <!-- </loaders>-->
      <!-- </namedCache> -->
      
      </infinispan>
      


      I find that using the config file I never got the persistance working. If I set up the persistance in code as per the InfinispanTest class posted on this forum, I can get the persistance to work.

      The config xml is loaded after the file store directory is set in code but the code seems to take precedence.

       Configuration cacheConfig = new Configuration();
       CacheLoaderManagerConfig cacheLoaders = new CacheLoaderManagerConfig();
       cacheLoaders.setPreload(true);
       FileCacheStoreConfig fileStoreConfig = new FileCacheStoreConfig();
       fileStoreConfig.setLocation("/temp/cacheStore");
       cacheLoaders.addCacheLoaderConfig(fileStoreConfig);
       cacheConfig.setCacheLoaderManagerConfig(cacheLoaders);
       CacheManager cm = new DefaultCacheManager("META-INF/cache-config.xml");
       cm.defineConfiguration("testCache", cacheConfig);
       Cache cache = cm.getCache("testCache");
       cache.start();
      


      David