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

Description

I removed the default cache settings from my ehache.xml file since I do not need it as I have named caches only.

I get a NPE exception when creating the CacheManager.

Caused by: java.lang.NullPointerException at net.sf.ehcache.config.Configuration$DefaultCache.access$100(Configuration.java:308) at net.sf.ehcache.config.Configuration.getDefaultCache(Configuration.java:129) at net.sf.ehcache.CacheManager.configure(CacheManager.java:159) at net.sf.ehcache.CacheManager.(CacheManager.java:121) at net.sf.ehcache.CacheManager.create(CacheManager.java:235) at at com.bmd.selfserviceejb.cache.BaseCacheManager.(BaseCacheManager.java:42).null(Unknown Source) ... 49 more

I think it should throw a CacheException instead or being able to work without a default cache. Sourceforge Ticket ID: 1025130 - Opened By: nobody - 9 Sep 2004 13:59 UTC

Comments

Sourceforge Tracker 2009-09-21

Logged In: YES user_id=693320

Currently when the default cache is used to create a new cache it emits a warning level log message. I think this is a good balance of convenience versus safety.

Originally I forced each cache to have a configuration. This turned out not to be convenient for the Hibernate people, who often forget to configure caches.

I agree that we can do better than an NPE. I have changed Configuration and CacheManager so that a CacheException is thrown with a message “Illegal configuration. No default cache is configured.”

I have also created a new test ConfiguratorTest#testLoadConfigurationFromFileNoDefault() to check that a CacheException is thrown.

Thanks for your bug report. Comment by: gregluck - 20 Sep 2004 02:58 UTC

Fiona OShea 2009-09-22

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