EHCache, terracotta hibernation versions

I have an application that is running Hibernate 4.1.7 and I am using ehcache as a level 2 cache. I understand that with Hibernate 4 I need to use the ehcache jars that come bundled with hibernate, but those jars are pretty old.

The current latest ehcache version is 2.6.3, but the version that ships with hibernate 4.1.7 is 2.4.3. The problem is hibernate is not bundled with ehcache-terracotta jar and my terracotta server comes bundled with ehcache-hibernate 2.6.2 jars as this is the last working version of terracotta. I am struggling to connect my app to my terracotta server and assume that this is because I have a version mismatch.

How do I get my ehcache used by hibernate (version 2.4.3) to connect to my terracotta server which is suitable for ehcache version 2.6.2?

Please, help

+3


source to share


1 answer


If you are using the Hibernate JPA implementation, you must specify the following property in your persistence.xml:

<property name="hibernate.cache.region.factory_class" value="net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory" />

      

Then you should have the following jars in your classpath (for terracotta version 3.6.5 is the latest JDK5 compatible version):

  • Ehcache-core-e-e-2.5.6.jar
  • Ehcache-terracotta-e-e-2.5.6.jar
  • ceramic tile-toolkit-1.5-environment-e-4.5.0.jar

Also, you should make sure that there are no other ehcache bins in your classpath.



if you are using maven then:

<dependency>
    <groupId>net.sf.ehcache</groupId>
    <artifactId>ehcache-core-ee</artifactId>
    <version>2.5.6</version>
</dependency>
<dependency>
    <groupId>net.sf.ehcache</groupId>
    <artifactId>ehcache-terracotta-ee</artifactId>
    <version>2.5.6</version>
</dependency>
<dependency>
    <groupId>org.terracotta</groupId>
    <artifactId>terracotta-toolkit-1.5-runtime-ee</artifactId>
    <version>4.5.0</version>
</dependency>

      

Also don't forget to point to the terracotta maven repository to load the required jars:

<repository>
    <id>terracotta-repository</id>
    <url>http://www.terracotta.org/download/reflector/releases</url>
    <releases>
        <enabled>true</enabled>
    </releases>
</repository>

      

+1


source







All Articles