grails多数据源无法运行应用程序

时间:2017-04-25 08:50:29

标签: hibernate grails multi-tenant

Holla在尝试在grails 2.4.4和hibernate 3上使用多数据源时遇到了麻烦。

一些研究建议升级到休眠4但是hibernate 3需要多租户单个数据库。

看起来这个问题与ehCache有关: 消息错误:

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:

我的数据源:

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
      }
...

buidConfig的部分:

插件{     //仅适用于构建系统的插件     build“:tomcat:7.0.55”     //用于编译步骤的插件     编译“:脚手架:2.1.2”     编译':cache:1.1.8'     编译“:asset-pipeline:1.9.9”     //在运行时需要插件,但不能用于编译   //运行时“:hibernate4:4.3.6.1”//或“:hibernate:3.6.10.18”     运行时“:hibernate:3.6.10.19”//适用于多租户     运行时“:数据库迁移:1.4.0”     运行时“:jquery:1.11.1”     //新     编译“:i18n-templates:1.1.0.1”     编译“:ckeditor:4.4.1.0”     //取消注释这些以启用其他资产管道功能     // 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”     //安全     编译“org.grails.plugins:spring-security-core:2.0.0”     编译“org.grails.plugins:spring-security-ui:1.0-RC3”     编译“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"

}

对此有任何想法 问候

1 个答案:

答案 0 :(得分:0)

Finnaly我已成功通过将我的hybernate降级为3.6.10.18来运行应用程序

但是我正面临一个新的错误,就在它开始创建时就像登录时的无限循环一样

WARN  intercept.RequestmapFilterInvocationDefinition  - Exception initializing; this is ok if it's at startup and due to GORM not being initialized yet since the first web request will re-initialize. Error message is: null source

关于如何解决它的任何想法