Singleton ehcache CacheManager warning fix

If you experience the following warning in your hibernate+ehcache application:

2008-11-20 13:02:42,937 WARN  (CacheManager.java:322) - 
  Creating a new instance of CacheManager using the diskStorePath 
  "D:\apache-tomcat-5.5.26\temp" which is already used by an 
  existing CacheManager.
The source of the configuration was classpath.
The diskStore path for this CacheManager will be set to 
  D:\apache-tomcat-5.5.26\temp\ehcache_auto_created_1227178962937.
To avoid this warning consider using the CacheManager factory 
  methods to create a singleton CacheManager or specifying a 
  separate ehcache configuration (ehcache.xml) for each 
  CacheManager instance.

then you need to set the following in your hibernate.cfg.xml file:

<property name="hibernate.cache.provider_class">
  net.sf.ehcache.hibernate.SingletonEhCacheProvider
</property>

Ehcache Hibernate documentation

6 Responses to “Singleton ehcache CacheManager warning fix”

  1. Renny Says:

    THANK YOU!!!!

  2. ioannis cherouvim » Blog Archive » Singleton ehcache CacheManager warning fix « Martin Schaaf’s Blog Says:

    [...] ioannis cherouvim » Blog Archive » Singleton ehcache CacheManager warning fix 2010 January 26 tags: detectAndFixDiskStorePathConflict, ehcache, hibernate, Programming by mascha ioannis cherouvim » Blog Archive » Singleton ehcache CacheManager warning fix. [...]

  3. Articles » Spring + JPA + Hibernate + Tomcat + EHCache Says:

    [...] I was getting a WARN message if I used org.hibernate.cache.EhCacheProvider. I referred to this post for a [...]

  4. cometta Says:

    you also need to add this line

    org.springframework.cache.ehcache.EhCacheManagerFactoryBean
    shared=true

    in your applicationcontext.xml

  5. jaime Says:

    In hibernate 3.6.1 you need this in persistence.xml (if using jpa)

    for ehcache 2.2.0

  6. jaime Says:

    property name=”hibernate.cache.region.factory_class” value=”net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory”