Showing results for 
Search instead for 
Did you mean: 

Creating new cache instance

Former Member
0 Kudos

I want to create a new KM cache which is not preconfigured.

According to

this should be possible with the getCache(String cacheID, Properties properties) method.

I tried the following code:

String cacheID = CacheFactory.getUniqueCacheID();

Properties cacheProp = new Properties(); cacheProp.setProperty(CacheFactory.CFG_MAX_CACHE_SIZE_KEY, "1000000"); cacheProp.setProperty(CacheFactory.CFG_CAPACITY_KEY, "500"); cacheProp.setProperty(CacheFactory.CFG_MAX_ENTRY_SIZE_KEY, "500");

cacheProp.setProperty(CacheFactory.CFG_AVERAGE_ENTRY_SIZE_KEY, "20000"); cacheProp.setProperty(CacheFactory.CFG_SINGLETON_KEY, "true");

cacheProp.setProperty(CacheFactory.CFG_DEFAULT_TIME_TO_LIVE_KEY, "0"); cacheProp.setProperty(CacheFactory.CFG_STORAGE_CLASS_KEY,CacheFactory.CFG_MEMORY_KEY);

try {

CacheFactory cacheFac = CacheFactory.getInstance();

cache = cacheFac.getCache(cacheID, cacheProp);

} catch (Exception e) {



Unfortunately I always get an exception. Is where any other property what I have to set?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos


Mandatory cache properties are:

CacheFactory.CFG_CACHE_CLASS_KEY, e.g. ICache.DEFAULT_CACHE_CLASS (for memory caches)

CacheFactory.CFG_CACHE_TYPE_KEY, e.g. CacheFactory.CFG_MEMORY_KEY (for memory caches)


CacheFactory.CFG_STORAGE_CLASS_KEY is needed only for persistent caches and will contain

a Java class that stores the content in the filesystem.

bye, Dirk

Answers (1)

Answers (1)

Former Member
0 Kudos


Please reproduce the exception /stack trace , so that we can help you out with your problem.



Former Member
0 Kudos

unfortunately the stack trace isn't very helpful:

com.sapportals.wcm.util.cache.CacheException at com.sapportals.wcm.util.cache.CacheFactory.getCache( at

com.test.TransformerHandler.( at

com.test.XSLTransformer.doContent( at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated( at com.sapportals.portal.prt.component.AbstractPortalComponent.service( at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent( at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest( at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest( at com.sapportals.portal.prt.component.PortalComponentResponse.include( at com.sapportals.portal.prt.pom.PortalNode.service( at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent( at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest( at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest( at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle( at com.sapportals.portal.prt.connection.ServletConnection.handleRequest( at com.sapportals.portal.prt.dispatcher.Dispatcher$ at Method) at com.sapportals.portal.prt.dispatcher.Dispatcher.service( at javax.servlet.http.HttpServlet.service( at at javax.servlet.http.HttpServlet.service( at at at at at at at at at at at at Method) at at

The code for instantiating the cache is in the TransformerHandler class.

Active Contributor
0 Kudos

Hi Achim,

the problem with the stack trace - as you've already stated - is that's it's not very helpful... If you check line 257 and above of the implementation, you will find a try/catch block of around 18 lines, where in the catch statement a new exception is thrown without providing the stack trace so far. Something which should never be done if the cause for the exception is non-ambiguous and can be passed into the new exception's text.

In such a case, I would advise to do one of the following two things:

- If you want a fast answer, modify the implementation to debug it or at least to get the real root cause; this way you maybe are able to repair the code or to pass valuable information directly to SAP's dev department.

- Open an OSS message with just the problem.

Hope it helps


PS: Please consider to reward points for helpful answers on SDN. Thanks in advance!