Clinton Bosch
Clinton Bosch

Reputation: 2589

EHCache, hibernate terracotta versions

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

The current latest version of ehcache is 2.6.3, but the version that comes with with hibernate 4.1.7 is 2.4.3. The problem is that hibernate does not come bundled with the ehcache-terracotta jar and my terracotta server comes bundled with ehcache-hibernate 2.6.2 jars since it is the latest working version of terracotta. I am struggling to get my application to connect to my terracotta server and assume it is because I have a mismatch in versions.

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

Please help

Upvotes: 3

Views: 1545

Answers (1)

user1697575
user1697575

Reputation: 2848

If you using Hibernate JPA implementation you should provide in your persistence.xml the following property:

<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 ver. 3.6.5 - the last version compatible with JDK5):

  • ehcache-core-ee-2.5.6.jar
  • ehcache-terracotta-ee-2.5.6.jar
  • terracotta-toolkit-1.5-runtime-ee-4.5.0.jar

Also, you have to make sure there are no any other ehcache jars on your classpath.

if you 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 terracotta's maven repository to download required jars:

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

Upvotes: 1

Related Questions