【问题标题】:grails multi datasources unable to run appgrails多数据源无法运行应用程序
【发布时间】:2017-09-22 04:24:54
【问题描述】:

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

一些研究建议升级到休眠 4,但休眠 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 部分:

插件{ // 仅用于构建系统的插件 构建“:tomcat:7.0.55” // 编译步骤的插件 编译“:脚手架:2.1.2” 编译':缓存:1.1.8' 编译“:资产管道:1.9.9” // 运行时需要但不用于编译的插件 // 运行时 ":hibernate4:4.3.6.1" // 或 ":hibernate:3.6.10.18" runtime ":hibernate:3.6.10.19"//多租户 运行时“:数据库迁移:1.4.0” 运行时“:jquery:1.11.1” //新的 编译 ":i18n-templates:1.1.0.1" 编译“:ckeditor:4.4.1.0” // 取消注释这些以启用额外的资产管道功能 //编译 ":sass-asset-pipeline:1.9.0" //编译 ":less-asset-pipeline:1.10.0" //编译 ":coffee-asset-pipeline:1.8.0" //编译 ":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"

}

关于这个的任何想法 问候

【问题讨论】:

    标签: hibernate grails multi-tenant


    【解决方案1】:

    最后我通过将我的 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
    

    关于如何修复它的任何想法

    【讨论】:

      猜你喜欢
      • 2013-11-03
      • 1970-01-01
      • 2016-07-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-28
      相关资源
      最近更新 更多