Drizzle_China
Drizzle_China

Reputation: 21

Terracotta toolkit missing class prevents EHCache from starting

I am new to EHCache and tried to use it as our cache server. I wrote the code trying to get started:

public class CacheMap {
    private static CacheManager cacheManager=new CacheManager("ehcache.xml");
    private static Cache cache=cacheManager.getCache("firstCache");
}

In classpath, I have included terracotta-toolkit-1.6-5.2.0.jar, terracotta-toolkit-1.6-runtime-5.0.0, slf4j-api-1.6.6, slf4j-jdk14-1.6.6, ehcache-2.7.0 and ehcache-ee-2.7.0

And I have ehcache.xml in my root directory.

However, I have got the following error on first line of my code:

Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: net.sf.ehcache.CacheException: Could not create ClusteredInstanceFactory due to missing class. Please verify that terracotta-toolkit is in your classpath.
    at net.sf.ehcache.terracotta.TerracottaClusteredInstanceHelper.newClusteredInstanceFactory(TerracottaClusteredInstanceHelper.java:187)
    at net.sf.ehcache.terracotta.TerracottaClient.createNewClusteredInstanceFactory(TerracottaClient.java:169)
    at net.sf.ehcache.terracotta.TerracottaClient.createClusteredInstanceFactory(TerracottaClient.java:126)
    at net.sf.ehcache.CacheManager.doInit(CacheManager.java:442)
    at net.sf.ehcache.CacheManager.init(CacheManager.java:392)
    at net.sf.ehcache.CacheManager.<init>(CacheManager.java:291)
    at CacheMap.<clinit>(CacheMap.java:7)

Any ideas how to get Terracotta working?

Upvotes: 1

Views: 3180

Answers (1)

user1697575
user1697575

Reputation: 2848

I think you have mixed required terracotta jars. If you use maven here are the dependencies for terracotta ver. 3.6.5 (the last version compatible with JDK5):

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

If you are not using maven, then you should have on your classpath the following jars:

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

Upvotes: 2

Related Questions