【问题标题】:Error with ehcacheMulticastGroupAddress setting up Grails Distributed CacheehcacheMulticastGroupAddress 设置 Grails 分布式缓存时出错
【发布时间】:2015-03-13 06:12:51
【问题描述】:

我正在通过尝试在不同端口上运行同一应用程序的两个不同版本来测试 Grails Ehcache 插件的分布式缓存。

在 BuildConfig 我有:

plugins {
    // plugins for the build system only
    build ":tomcat:7.0.55"

    // plugins for the compile step
    compile ":cache-ehcache:1.0.4"

    // plugins needed at runtime but not for compilation
    runtime ":hibernate4:4.3.6.1" 
    runtime ":database-migration:1.4.0"
    runtime ":jquery:1.11.1"

}

应用程序将运行并正确缓存域对象。

当我将以下配置添加到 Config.groovy 或 CacheConfig.groovy(并通过 grails.config.locations 包含它)时,我收到以下错误:

Message: Could not create CacheManagerPeerProvider. Initial cause was ${ehcacheMulticastGroupAddress}
    Line | Method
->>   63 | createCachePeerProvider  in net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    136 | createCachePeerProviders in net.sf.ehcache.config.ConfigurationHelper
|    795 | configure . . . . . . .  in net.sf.ehcache.CacheManager
|    471 | doInit                   in     ''
|    395 | init . . . . . . . . . . in     ''
|    177 | rebuild                  in grails.plugin.cache.ehcache.GrailsEhCacheManagerFactoryBean$ReloadableCacheManager
|     63 | reload . . . . . . . . . in grails.plugin.cache.ehcache.EhcacheConfigLoader
|     42 | reload                   in grails.plugin.cache.ConfigLoader
|    204 | reloadCaches . . . . . . in CacheGrailsPlugin
|    161 | doCall                   in CacheGrailsPlugin$_closure3
|    334 | innerRun . . . . . . . . in java.util.concurrent.FutureTask$Sync
|    166 | run                      in java.util.concurrent.FutureTask
|   1145 | runWorker . . . . . . .  in java.util.concurrent.ThreadPoolExecutor
|    615 | run                      in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . . . . . . . .  in java.lang.Thread

Caused by UnknownHostException: ${ehcacheMulticastGroupAddress}
->>  894 | lookupAllHostAddr        in java.net.InetAddress$1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1286 | getAddressesFromNameService in java.net.InetAddress
|   1239 | getAllByName0 . . . . .  in     ''
|   1155 | getAllByName             in     ''
|   1091 | getAllByName . . . . . . in     ''
|   1041 | getByName                in     ''
|    113 | createAutomaticallyConfiguredCachePeerProvider in net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory
|     61 | createCachePeerProvider  in     ''
|    136 | createCachePeerProviders in net.sf.ehcache.config.ConfigurationHelper
|    795 | configure                in net.sf.ehcache.CacheManager
|    471 | doInit . . . . . . . . . in     ''
|    395 | init                     in     ''
|    177 | rebuild . . . . . . . .  in grails.plugin.cache.ehcache.GrailsEhCacheManagerFactoryBean$ReloadableCacheManager
|     63 | reload                   in grails.plugin.cache.ehcache.EhcacheConfigLoader
|     42 | reload . . . . . . . . . in grails.plugin.cache.ConfigLoader
|    204 | reloadCaches             in CacheGrailsPlugin
|    161 | doCall . . . . . . . . . in CacheGrailsPlugin$_closure3
|    334 | innerRun                 in java.util.concurrent.FutureTask$Sync
|    166 | run . . . . . . . . . .  in java.util.concurrent.FutureTask
|   1145 | runWorker                in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . . . . . . . .  in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run                      in java.lang.Thread

【问题讨论】:

  • 因此,如果我将其打包为一个战争并部署到本地运行的 Tomcat 版本,应用程序运行良好。

标签: java grails caching ehcache


【解决方案1】:

您的 Ehcache 配置似乎有一个未解析的变量:${ehcacheMulticastGroupAddress}

【讨论】:

  • 是的。由于 java.net.InetAddress 中的解析问题,看起来该变量未解析。但为什么呢?
  • 不,恰恰相反。该变量需要首先解析为主机名,以便可以打开与它的连接。我不太了解 Grails,所以不确定您是否有 ehcache.xml,但请查看那里或在 grails 配置文件中替换值。
  • 当应用程序部署到 Tomcat 时,变量似乎存在,而不是在运行 grails run-app 时存在,这很有意义。只是让在 localhost 上的测试有点棘手但可行。
猜你喜欢
  • 2021-06-22
  • 1970-01-01
  • 2014-12-02
  • 2020-09-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多