Apache Commons logo

Commons JCS™

Upgrading from JCS 2.x to 3.0

This document lists a number of things that changed in Commons JCS 3.0.

Minimum Java Requirements

JCS 3.x requires Java 8 to run. It was tested successfully with JDK 14.

Package Names and Maven Coordinates

The Apache Commons project requires a change of the package names and Maven coordinates on a major release. So in all your code replace

import org.apache.commons.jcs.*;
with
import org.apache.commons.jcs3.*;
The Maven coordinates change from
<dependency>
    <groupId>org.apache.commons.jcs</groupId>
    <artifactId>commons-jcs-core</artifactId>
    <version>2.2.1</version>
</dependency>
to
<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-jcs3-core</artifactId>
    <version>3.0</version>
</dependency>

Adjusting the Configuration

Here again, change all package names in configuration entries from e.g.

jcs.default.cacheattributes=org.apache.commons.jcs.engine.CompositeCacheAttributes
to
jcs.default.cacheattributes=org.apache.commons.jcs3.engine.CompositeCacheAttributes

Logging Abstraction

JCS 3.0 uses its own log abstraction layer. As newer and better log systems become available, JCS is no longer limited to commons-logging. As a result, JCS now uses java.util.logging as default and does not depend on commons-logging anymore.

Optionally, JCS can use Log4j2 as a log system. You can activate it by providing log4j-core as a dependency, a log configuration such as log4j2.xml and a system property

-Djcs.logSystem=log4j2
As log initialization occurs very early in the startup process, be sure to add this property before accessing any of JCS' classes.

JCS uses the Java SPI mechanism to find its log systems. If you want to roll your own, you will need to implement a org.apache.commons.jcs.log.Log object and a org.apache.commons.jcs.log.LogFactory and provide the implementation class in a text file META-INF/services/org.apache.commons.jcs.log.LogFactory in your code. Choose a name for your log system and activate it via the system property as described above.