• Bug
  • Status: Closed
  • Resolution: Fixed
  • drb
  • Reporter: sourceforgetracker
  • September 21, 2009
  • 0
  • Watchers: 0
  • September 22, 2009
  • September 22, 2009


I just started using ehcache. I specifically want to:

  1. have multiple instances (no singleton)
  2. have no external configuration files (ehcache.xml)
  3. not use disk storage

With that in mind, I wrote the following:

// in a constructor some class: this.cacheManager = new CacheManager(makeCacheConfig());

// within the same class: private static Configuration makeCacheConfig() { Configuration config = new Configuration(); CacheConfiguration defaults = new CacheConfiguration(); defaults.setEternal(true); defaults.setDiskPersistent(false); defaults.setOverflowToDisk(false); defaults.setMaxElementsInMemory(MAX_CACHE_ELEMENTS); config.setDefaultCacheConfiguration(defaults); return config; }

This works fine for one instance of CacheManager. When I create multiple instances of CacheManager in this way, I get a NullPointerException:

java.lang.NullPointerException at net.sf.ehcache.CacheManager.detectAndFixDiskStorePathConflict (CacheManager.java:269) at net.sf.ehcache.CacheManager.configure(CacheManager.java:252) at net.sf.ehcache.CacheManager.init(CacheManager.java:196) at net.sf.ehcache.CacheManager.( CacheManager.java:114)

For now, the workaround I’m using is to configure a (bogus) disk store. But this also means that I have to generate a unique bogus name for each disk store.

In addition to fixing the NPE, please please please enhance the documentation (javadoc, user guide) with respect to programmatic configuration. It would be nice to have a reference of all of the required and optional parameters and values. Sourceforge Ticket ID: 1593099 - Opened By: nobody - 9 Nov 2006 02:27 UTC


Fiona OShea 2009-09-22

Re-opening so that I can properly close out these issues and have correct Resolution status in Jira