Exception thrown after configuring ehcache.xml in grails application

In my quest to personalize ehcache in my grails application, I added the following xml to the configuration directory:

<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd" >
<diskStore path="/path/to/store/data"/>
<cacheManagerEventListenerFactory class="" properties=""/>
<defaultCache
   maxEntriesLocalHeap="10000"
   eternal="false"
   timeToLiveSeconds="120">
   <persistence strategy="none"/>
</defaultCache>
<cache name="Book"
  maxEntriesLocalHeap="10000"
  timeToIdleSeconds="300"
   />
<cache name="org.hibernate.cache.UpdateTimestampsCache"
  maxEntriesLocalHeap="10000"
  timeToIdleSeconds="300"
   />
<cache name="org.hibernate.cache.StandardQueryCache"
  maxEntriesLocalHeap="10000"
  timeToIdleSeconds="300"
   />
</ehcache>

To my surprise, at launch, the grails application terminates with the exception:

Caused by: net.sf.ehcache.CacheException: Error configuring from input stream. Initial  cause was null:9: Element <defaultCache> does not allow attribute "maxEntriesLocalHeap".
at    net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:152)
at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:99)
... 30 more

Any clues? I am using grails 1.3.9; thank.

+5
source share
5 answers

It turned out the same problem with Spring, maxEntriesLocalHeapand maxEntriesLocalDisk. It seems to have been used for me as maxElementsInMemorywell maxElementsOnDisk. Found from javadoc .

Now, based on the fact that they are outdated, I believe that there was an earlier version of EHCache that works with my config, as well as yours.

, maxEntriesLocalHeap EHCache 2.5. maxElementsInMemory. , ehcache-spring-annotations, 1.2.0, ehcache 2.4.5 - , .

Spring EHCache 2.5 , , .

+8

Ehcache (2.6.x) , maxEntriesLocalHeapEhcache "persistence".

: A) 'maxElementsInMemory' ( 'maxEntriesLocalHeap'); "overflowToDisk" "diskPersistent" ( "persistence" ),... B) .

+3

Hibernate

4.3.5 4.3.7 Ehcache 2.4.7 , maxEntriesLocalHeap maxEntriesLocalDisk.

Ehcache 2.4.x: http://ehcache.org/files/documentation/EhcacheUserGuide.pdf

hibernate 4.3.5:

<defaultCache maxElementsInMemory="10000"
              eternal="false"
              timeToIdleSeconds="300"
              timeToLiveSeconds="600"
              diskSpoolBufferSizeMB="30"
              maxElementsOnDisk="10000"
              diskExpiryThreadIntervalSeconds="120"
              memoryStoreEvictionPolicy="LRU" statistics="false">
</defaultCache>

<cache
        name="org.hibernate.cache.spi.UpdateTimestampsCache"
        maxElementsInMemory="10000"
        eternal="false">
</cache>

<cache
        name="org.hibernate.cache.internal.StandardQueryCache"
        maxElementsInMemory="10000"
        eternal="false"
        timeToLiveSeconds="300">
</cache>

<!--
If you are concerned about cpu utilisation and locking in the DiskStore, you can set the
diskExpiryThreadIntervalSeconds to a high number - say 1 day. Or you can effectively turn it off by
setting the diskExpiryThreadIntervalSeconds to a very large value
-->
<cache
        name="br.com.atlantico.toi.model.calc.Anomalia"
        maxElementsInMemory="10000"
        eternal="false"
        timeToIdleSeconds="300"
        timeToLiveSeconds="600"/>

0

, eis, Hibernate-ehcache ehcache 2.4.3, verion. ehcache.

:

-, hibernate-ehcache, ehcache-core maven pom.

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-ehcache</artifactId>
    <version>${hibernate.version}</version>
</dependency>
<dependency>
    <groupId>net.sf.ehcache</groupId>
    <artifactId>ehcache-core</artifactId>
    <version>2.6.5</version>
</dependency>

Then set the property for the factory session in the spring configuration. Use classes from org.hibernate., Not from net.sf.ehcache.

<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory </prop>
0
source

I ran into a similar problem and I decided to use the following banks.

  • ehcache.2.9.jar
  • logback-core-1.0.13.jar
  • Logback-Classic 1.0.13.jar

you add above jars to your project path .. it will work fine.

0
source

All Articles