Grails ehcache plugin - Another unnamed CacheManager already exists in the same VM

戏子无情 提交于 2019-12-05 10:43:32
Joshua Swink

In the hibernate section of DataSource.groovy, make sure your cache.provider.class is up to date:

hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = true
    cache.region.factory_class = 'grails.plugin.cache.ehcache.hibernate.BeanEhcacheRegionFactory' // For Hibernate before 4.0
    cache.region.factory_class = 'grails.plugin.cache.ehcache.hibernate.BeanEhcacheRegionFactory4' // For Hibernate before 4.0 and higher
}

I had the same problem because my cache.region.factory_class was outdated: net.sf.ehcache.hibernate.EhCacheProvider.

See http://grails-plugins.github.io/grails-cache-ehcache/guide/usage.html

For those having this error with Grails 2.5.x, just add this to Config.groovy :

beans {
   cacheManager {
      shared = true
  }
}

This solved the problem for me.

source : https://github.com/grails/grails-core/releases/tag/v2.5.0

Try to use cache & cache-ehcache plugins, it works for me with some limitations. But for 2ndlevel Cache it work correctly

For people arriving here getting the same error as OP might consider that error might be caused by an update of a domain class at runtime (hot code swap), which is not done nicely in alle versions of Grails.

I hit this bug with Grails 2.5.4, yet with the application restart button as the only option to solve.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!