Holla i'm facing trouble when trying to use multi datasource on grails 2.4.4 and hibernate 3.
Some research propose to upgrate to hibernate 4 but the hibernate 3 is need for multitenant single db.
It's look like that the probleme is relative to ehCache: message error:
Error |
2017-04-25 08:46:00,889 [localhost-startStop-1] ERROR context.GrailsContextLoaderListener - Error initializing the application: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'transactionManager_paie' while setting constructor argument with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager_paie': Cannot resolve reference to bean 'sessionFactory_paie' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory_paie': Invocation of init method failed; nested exception is org.hibernate.cache.CacheException: 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 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 ]
Message: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'transactionManager_paie' while setting constructor argument with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager_paie': Cannot resolve reference to bean 'sessionFactory_paie' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory_paie': Invocation of init method failed; nested exception is org.hibernate.cache.CacheException: 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 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 ]
Line | Method
->> 262 | run in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'transactionManager_paie' while setting constructor argument with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager_paie': Cannot resolve reference to bean 'sessionFactory_paie' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory_paie': Invocation of init method failed; nested exception is org.hibernate.cache.CacheException: 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:
my datasource:
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3
//cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4
//singleSession = true // configure OSIV singleSession mode
naming_strategy = sn.rh.base.CustomNamingStrategy
//cache.provider_class = 'net.sf.ehcache.hibernate.SingletonEhCacheProvider'
}
environments {
development{
dataSource {
dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
driverClassName = "com.mysql.jdbc.Driver"
dialect=org.hibernate.dialect.MySQL5InnoDBDialect
url = "jdbc:mysql://localhost:3306/portailrh?autoreconnect=true"
username = "user"
password = "user"
pooled = true
// logSql = true
}
dataSource_paie { //Convention is dataSource_name
dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
driverClassName = "com.mysql.jdbc.Driver"
url = "jdbc:mysql://localhost:3306/paie?autoreconnect=true"
dialect=org.hibernate.dialect.MySQL5InnoDBDialect
username = "user"
password = "user"
// pooled = true
}
...
the section of buidConfig:
plugins { // plugins for the build system only build ":tomcat:7.0.55" // plugins for the compile step compile ":scaffolding:2.1.2" compile ':cache:1.1.8' compile ":asset-pipeline:1.9.9" // plugins needed at runtime but not for compilation // runtime ":hibernate4:4.3.6.1" // or ":hibernate:3.6.10.18" runtime ":hibernate:3.6.10.19"//for multi tenant runtime ":database-migration:1.4.0" runtime ":jquery:1.11.1" //new compile ":i18n-templates:1.1.0.1" compile ":ckeditor:4.4.1.0" // Uncomment these to enable additional asset-pipeline capabilities //compile ":sass-asset-pipeline:1.9.0" //compile ":less-asset-pipeline:1.10.0" //compile ":coffee-asset-pipeline:1.8.0" //compile ":handlebars-asset-pipeline:1.3.0.3" //security compile "org.grails.plugins:spring-security-core:2.0.0" compile "org.grails.plugins:spring-security-ui:1.0-RC3" compile "org.grails.plugins:mail:1.0.7"
//multi societe0.9.0-SNAPSHOT"
compile "org.grails.plugins:multi-tenant-single-db:0.8.3"
//excel import
compile ":excel-import:2.0.0.BUILD-SNAPSHOT"
//audit log
compile "org.grails.plugins:audit-logging:1.1.1"
//test weceem
//compile ':weceem:1.4.1'
//compile ":weceem-spring-security:1.4"
//standalone
compile "org.grails.plugins:standalone:8.0.33"//8.0.33
//sms twilio
compile "org.grails.plugins:twilio:0.1"
//sms nexmo
compile "org.grails.plugins:nexmo:1.0"
}
Any idea about this regards