2

I am using JCS which I have used before in the same way without any problem.

When the server starts up I am setting the cache properties manually

CompositeCacheManager ccm = CompositeCacheManager.getUnconfiguredInstance();
Properties props = new Properties();

    props.put("jcs.default", "");
    props.put("jcs.default.cacheattributes", "org.apache.jcs.engine.CompositeCacheAttributes");
    props.put("jcs.default.cacheattributes.MaxObjects", "1000");
    props.put("jcs.default.cacheattributes.MemoryCacheName", "org.apache.jcs.engine.memory.lru.LRUMemoryCache");
    props.put("jcs.default.cacheattributes.UseMemoryShrinker", "true");
    props.put("jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds", "3600");
    props.put("jcs.default.cacheattributes.ShrinkerIntervalSeconds", "60");
    props.put("jcs.default.elementattributes", "org.apache.jcs.engine.ElementAttributes");
    props.put("jcs.default.elementattributes.IsEternal", "false");

    ccm.configure(props);

When setting this way an error is being thrown

org.apache.jcs.engine.CompositeCacheAttributes cannot be cast to org.apache.commons.jcs.engine.behavior.ICompositeCacheAttributes

I have used this exact same method on other projects without problem. Why am I getting this exception now?

EDIT

I am getting the JCS jar file from

<dependency>
    <groupId>org.apache.jcs</groupId>
    <artifactId>jcs</artifactId>
    <version>1.3</version>
</dependency>

Prior to this I also tried to get the 2.0-beta version with the same problem

EDIT 2

I have opened a ticket in Jira, should anyone else be facing the same problem and wish to follow.

L. Young
  • 163
  • 3
  • 7
  • 24

1 Answers1

0

After a couple of tries, had found that this issue is with the dependencies. Below set of dependencies worked for me

    <dependency>
        <groupId>org.apache.jcs</groupId>
        <artifactId>jcs</artifactId>
        <version>1.3</version>
    </dependency>

    <dependency>
        <groupId>concurrent</groupId>
        <artifactId>concurrent</artifactId>
        <version>1.3.4</version>
    </dependency>

INSTEAD OF -

    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.2</version>
    </dependency>

    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-jcs-core</artifactId>
        <version>2.2</version>
    </dependency>

Selecting the right set of dependencies solved the problem for me.

Harshit
  • 109
  • 5
  • 19