I'm trying to develop a grails 2.4.X plugin to add domain objects. When I run my application I get this in the application including the plugin:
Caused by CacheException: Another unnamed CacheManager already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following:
1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary
2. Shutdown the earlier cacheManager before creating new one with same name.
The source of the existing CacheManager is: DefaultConfigurationSource [ ehcache.xml or ehcache-failsafe.xml ]
->> 628 | assertNoCacheManagerExistsWithSameName in net.sf.ehcache.CacheManager
I assume that DataSource and Config (in the plugin) are over-written.
I updated the plugin to use to use BeanEhcacheRegionFactory4:
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
// cache.region.factory_class = 'net.sf.ehcache.hibernate.BeanEhcacheRegionFactory' // Hibernate 3
cache.region.factory_class = 'org.hibernate.cache.ehcache.BeanEhcacheRegionFactory4' // Hibernate 4
singleSession = true // configure OSIV singleSession mode
flush.mode = 'manual' // OSIV session flush mode outside of transactional context
}
Grails ehcache plugin - Another unnamed CacheManager already exists in the same VM
I don't have an ehcache.xml so I'm assuming it is using the groovy configuration.
Is this something that would be fixed by moving to 2.5 / 3?
Removing the ehcache plugin "fixes" this problem.