Open
Description
Error
I am trying to use the cache for the first time. But unfortunately I get the following message on the server
15:13:11,642 ERROR [ch.coop.workflow.component.hrservices.cache.AbstractWorkforceIdKeyCache] (default task-30) Error: java.lang.LinkageError: Cannot resolve cache2k core implementation
at org.cache2k.CacheManager.<clinit>(CacheManager.java:64)
at org.cache2k.Cache2kBuilder.cfg(Cache2kBuilder.java:186)
at org.cache2k.Cache2kBuilder.name(Cache2kBuilder.java:342)
at ch.coop.workflow.component.hrservices.cache.AbstractWorkforceIdKeyCache.initCache(AbstractWorkforceIdKeyCache.java:29)
at ch.coop.workflow.component.hrservices.cache.AbstractWorkforceIdKeyCache.getCache(AbstractWorkforceIdKeyCache.java:22)
at ch.coop.workflow.component.hrservices.cache.MaOrgDatCache.getDocument(MaOrgDatCache.java:24)
at ch.coop.workflow.component.hrservices.HRServicesService.zHRGetMitarbeiterOrgDat(HRServicesService.java:173)
Setting
- SLES 12
- Adobe AEM J2EE Forms 6.5
- JBoss EAP 6.2.0.GA (AS 7.3.0.Final-redhat-14)
- Java 1.8
- Maven 3.6.3
- Eclipse IDE
pom.xml
<properties>
<jdk-version>1.8</jdk-version>
<cache2k-version>2.6.1.Final</cache2k-version>
</properties>
<dependencies>
<!-- CACHE -->
<dependency>
<groupId>org.cache2k</groupId>
<artifactId>cache2k-api</artifactId>
<version>${cache2k-version}</version>
</dependency>
<dependency>
<groupId>org.cache2k</groupId>
<artifactId>cache2k-core</artifactId>
<version>${cache2k-version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
implementation
package ch.coop.workflow.component.hrservices.cache;
import java.util.concurrent.TimeUnit;
import org.cache2k.Cache;
import org.cache2k.Cache2kBuilder;
import org.cache2k.io.CacheLoader;
import org.w3c.dom.Document;
import ch.coop.workflow.component.hrservices.cache.functions.WorkforceIdKeyFunction;
import ch.coop.workflow.component.hrservices.cache.keys.WorkforceIdKey;
public abstract class AbstractWorkforceIdKeyCache {
protected AbstractWorkforceIdKeyCache() {
}
protected static Cache<WorkforceIdKey, Document> getCache(WorkforceIdKeyFunction fn, String cacheName) {
return initCache(fn, cacheName);
}
private static Cache<WorkforceIdKey, Document> initCache(WorkforceIdKeyFunction fn, String cacheName) {
return new Cache2kBuilder<WorkforceIdKey, Document>() {
}
.name(cacheName)
.entryCapacity(1000)
.refreshAhead(true)
.loaderThreadCount(3)
.expireAfterWrite(60, TimeUnit.MINUTES)
.loader(new CacheLoader<WorkforceIdKey, Document>() {
@Override
public Document load(WorkforceIdKey key) throws Exception {
return fn.reload(key);
}
})
.build();
}
}
package ch.coop.workflow.component.hrservices.cache;
import org.apache.log4j.Logger;
import org.cache2k.Cache;
import org.w3c.dom.Document;
import ch.coop.workflow.common.exception.SystemException;
import ch.coop.workflow.component.hrservices.cache.keys.WorkforceIdKey;
import ch.coop.workflow.component.hrservices.dao.SAPModuleDAO;
public class MaOrgDatCache extends AbstractWorkforceIdKeyCache {
private static final Logger LOGGER = Logger.getLogger(MaOrgDatCache.class);
private static SAPModuleDAO sapDAO;
private static Cache<WorkforceIdKey, Document> cache;
private MaOrgDatCache() {
}
public static Document getDocument(WorkforceIdKey key, SAPModuleDAO service) {
sapDAO = service;
if (cache == null) {
cache = getCache(MaOrgDatCache::reload, "MaOrgDatCache");
}
try {
return cache.get(key);
} catch (Exception e) {
String message = String.format("error loading Z_HR_GET_MITARBEITER_ORG_DAT with %s", key);
LOGGER.error(message, e);
throw new SystemException(message);
}
}
protected static Document reload(WorkforceIdKey key) {
Document doc = sapDAO.zHRGetMitarbeiterOrgDat(key.getXmlDate(), key.getWorkforceId());
if (doc == null) {
String message = "document is null";
throw new SystemException(message);
}
return doc;
}
}
I do not get any error in Eclipse during execution of the test cases.
Do I need to implement/use the cache differently?
Metadata
Metadata
Assignees
Labels
No labels