Reputation: 1861
I'm facing problem with grails spring-security-core plugin/spring-ldap plugin. Here is my first post link, and full stacktrace. Here is the problem:
I have an app with multpile datasources and spring-security-core plugin added by
`build.gradle ` `compile "org.grails.plugins:spring-security-core:3.1.1"`
running this app in build in tomcat server, it works great, but when I try to deploy war file in my own tomcat, it fails with error (in the link), i have been trying to find what cause it, first solution is turning off second level cache, second solution is removing spring-security-core plugin from project. I don't know if it is a bug or maybe I'm missing some configuration, maybe default configuration is not enough?. Project was working in previous grails version 3.0.x. If you want to reproduce error simply create new grails project - with web profile, add more then one datasource (oracle,mssql) and try to deploy it on tomcat.
I thought it may be some problem with plugin dependencies because it also uses ehcache, and i have dependency to hibernate-ehcache
, but excluding ehcache-core
didnt help. Here is repo with sample project which fails link
Upvotes: 3
Views: 497
Reputation: 10848
Not sure if you have noticed it, but your stacktrace states clearly that you have create a duplicate CacheManager. You may want to check your ehcache.xml or ehcache-failsafe.xml
Caused by: org.hibernate.cache.CacheException: net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the
ame 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 necessa
y
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 ]
at org.hibernate.cache.ehcache.EhCacheRegionFactory.start(EhCacheRegionFactory.java:107)
at org.hibernate.internal.CacheImpl.<init>(CacheImpl.java:70)
at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:40)
at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:35)
at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.initiateService(SessionFactoryServiceRegistryImpl.jav
:91)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:251)
... 74 common frames omitted
Caused by: net.sf.ehcache.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 necessa
y
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 ]
UPDATE: you may want to consider the configuration of this similar question. Basically they are using a shared singleton bean, so it would avoid the re-creation of the cache:
DataSource.Groovy:
cache.region.factory_class = 'org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory'
and
Config.groovy:
cacheManager {
shared = true
}
I'm not sure if it is indeed your case or not (we don't see your configuration), but it's a start.
Upvotes: 3