سؤال

Have such ehcache configuration:

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

It does not work, application just does not conntects to terracotta server, however during startup it throws such Exception:

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

When I enabled ehcache debug logs, I don't see that my ehcache.xml is loaded somewhere (althrough another ehcache.xml which sits on the classpath inside some jar file is loaded). What could be a problem?

My grails version is 2.1.1, ehcache.xml sits on grails-app/conf directory.

UPDATE 1 One more explanation. cache named foo is used in ehcache.xml and in the code as referece (actually in Apache Camel route as to('cache://foo'). When I rename foo in code to bar (e.g. route now looks like to('cache://bar') it throws the exception that Cache bar already exists. So, exception comes not from ehcache.xml configuration file, but from code referencing that cache by name. Any suggestions would be highly appreciated.

UPDATE 2 Seems the exception is thrown because there are 2 places inside camel routes where cache://foo is referenced. When 2nd reference is reached it throws that exception. So the main question is, why ehcache.xml is not seen by the application on startup? It should warm up and prepare cache://foo for future use.

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

هل كانت مفيدة؟

المحلول

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top