• Bug
  • Status: Closed
  • 2 Major
  • Resolution: Fixed
  • ehcache-core
  • hsingh
  • Reporter: hsingh
  • November 05, 2009
  • 0
  • Watchers: 0
  • January 17, 2013
  • November 06, 2009

Attachments

Description

Get following exception on setting diskStorePath

Creating cache … Disk Store: C:\DOCUME~1\hsingh\LOCALS~1\Temp\ isDirectory : true canWrite : true isAbsolute : true Exception in thread “main” net.sf.ehcache.CacheException: regionNameCache: Could not create disk store. Initial cause was null at net.sf.ehcache.store.DiskStore.(DiskStore.java:176) at net.sf.ehcache.Cache.createDiskStore(Cache.java:733) at net.sf.ehcache.Cache.initialise(Cache.java:681) at net.sf.ehcache.CacheManager.addCacheNoCheck(CacheManager.java:821) at net.sf.ehcache.CacheManager.addCache(CacheManager.java:811) at net.sf.ehcache.CacheManager.addCache(CacheManager.java:789) at org.tc.ProgramaticallyCreateEhcache.(ProgramaticallyCreateEhcache.java:39) at org.tc.ProgramaticallyCreateEhcache.main(ProgramaticallyCreateEhcache.java:44) Caused by: java.lang.NullPointerException at java.io.File.(File.java:222) at net.sf.ehcache.store.DiskStore.initialiseFiles(DiskStore.java:184) at net.sf.ehcache.store.DiskStore.(DiskStore.java:164) ... 7 more

Comments

gluck 2009-11-05

There are quite a few people who want to use ehcache memory only. Disk paths if used need to be unique. We have an autoresolver but that issues a warning which also disturbs people. Some use cases: more than one CacheManager in a VM and a company that is deploying multiple applications on one server. or running n ASP app where they have lots of instances on one server. This tends to be a deployment issue.

If a CacheManager is configured not to have a disk path we should not permit creating of caches with disk stores. So I think the current behaviour is intended and important.

Looking at the stack trace

Exception in thread “main” net.sf.ehcache.CacheException: regionNameCache: Could not create disk store. Initial cause was null

we should change it so that it says:

regionNameCache: Could not create disk store. This CacheManager configuration does not allow creation of DiskStores. If you wish to create DiskStores, please configure a diskStore path.

Himadri Singh 2009-11-06

Not sure how do we set diskStore in ehcache.xml but through java adding DiskStoreConfiguration to cache manager config makes it work fine without any exceptions.

    DiskStoreConfiguration diskStoreConfigurationParameter = new DiskStoreConfiguration();
    String diskStore = System.getProperty("java.io.tmpdir") + "/"+ cacheManagerName;
    diskStoreConfigurationParameter.setPath(diskStore);
    config.addDiskStore(diskStoreConfigurationParameter);

Chris Dennis 2009-11-06

Resolved by changing the log message to be as Greg suggested. Also added test coverage to CacheManagerTest to ensure this fails correctly.

Himadri Singh 2009-11-16

New message

Exception in thread “main” net.sf.ehcache.CacheException: regionNameCache: Could not create disk store. Initial cause was regionName Cache: Could not create disk store. This CacheManager configuration does not allow creation of DiskStores. If you wish to create DiskStores, please configure a diskStore path. at net.sf.ehcache.store.DiskStore.(DiskStore.java:177) at net.sf.ehcache.Cache.createDiskStore(Cache.java:732) at net.sf.ehcache.Cache.initialise(Cache.java:682) at net.sf.ehcache.CacheManager.addCacheNoCheck(CacheManager.java:811) at net.sf.ehcache.CacheManager.addCache(CacheManager.java:801) at net.sf.ehcache.CacheManager.addCache(CacheManager.java:779) at org.tc.ProgramaticallyCreateEhcache.(ProgramaticallyCreateEhcache.java:39) at org.tc.ProgramaticallyCreateEhcache.main(ProgramaticallyCreateEhcache.java:44) Caused by: net.sf.ehcache.CacheException: regionName Cache: Could not create disk store. This CacheManager configuration does not allow creation of DiskStores. If you wish to create DiskStores, please configure a diskStore path. at net.sf.ehcache.store.DiskStore.initialiseFiles(DiskStore.java:185) at net.sf.ehcache.store.DiskStore.(DiskStore.java:165) ... 7 more