0

有这样的ehcache配置:

<ehcache>                                                                                                                                                                                                                                      

  <terracottaConfig url="192.168.1.4:9510"/>                                                                                                                                                                                                           

  <defaultCache                                                                                                                                                                                                                                
      maxElementsInMemory="50"                                                                                                                                                                                                                 
      eternal="false"                                                                                                                                                                                                                          
      timeToIdleSeconds="20"                                                                                                                                                                                                                   
      timeToLiveSeconds="20"                                                                                                                                                                                                                   
      overflowToDisk="false"                                                                                                                                                                                                                   
      diskPersistent="false"                                                                                                                                                                                                                   
      memoryStoreEvictionPolicy="LRU"                                                                                                                                                                                                          
      />                                                                                                                                                                                                                                       

  <cache name="foo"                                                                                                                                                                                                              
         maxElementsInMemory="50000"                                                                                                                                                                                                           
         eternal="true">                                                                                                                                                                                                                       
    <terracotta />                                                                                                                                                                                                                             
  </cache>                                                                                                                                                                                                                                     

</ehcache> 

它不起作用,应用程序只是不连接到terracotta服务器,但是在启动期间它会抛出这样的异常:

 net.sf.ehcache.ObjectExistsException: Cache foo already exists. 

当我启用ehcache调试日志时,我看不到我ehcache.xml的已加载到某个地方(尽管加载了另一个ehcache.xml位于某个 jar 文件内的类路径上)。可能是什么问题?

我的grails版本是2.1.1ehcache.xml位于grails-app/conf目录上。

更新 1 更多解释。缓存命名在代码fooehcache.xml和代码中用作参考(实际上在 Apache Camel 路由中作为 to('cache://foo')。当我foo在代码中重命名为时bar(例如,路由现在看起来像 to('cache://bar' ) 它抛出异常Cache bar already exists。因此,异常不是来自ehcache.xml配置文件,而是来自按名称引用该缓存的代码。任何建议都将受到高度赞赏。

更新 2 似乎引发了异常,因为骆驼路线中有 2 个地方cache://foo被引用。当达到第二个引用时,它会抛出该异常。所以主要问题是,为什么ehcache.xml应用程序在启动时看不到?它应该预热并cache://foo为将来的使用做准备。

UPDATE 3 It apparently worked before on grails 1.3.7. And now it does not work on grails 2.1.1

4

1 回答 1

0

When I run grails with -noreloading option it works well. Must be some classpath issue.

于 2013-01-10T10:53:18.107 回答