Issue
- The custom cache entity we introduced to Liferay is inaccessible. We configured our custom cache in override-liferay-multi-vm-clustered.xml. When trying to access the custom cache entity from scripting console by:
MultiVMPoolUtil.getPortalCache("com.custom.service.model.impl.AnyImpl").getKeys();DXP 7.1 throws:
com.liferay.portal.cache.ehcache.LiferayCacheEventListenerFactory cannot be found by com.liferay.portal.cache.ehcache.impl_1.0.12
Environment
- DXP 7.1 , DXP 7.0 (Fix pack 28+)
Resolution
- Custom cache can be configured two ways: a) the plugin way or b) the xml way which is the case here. Please find the steps below.
1./ tune the following portal property in portal-ext.properties:
ehcache.replicator.properties.${specific.cache.name}=As an example:
ehcache.replicator.properties.com.custom.service.model.impl.AnyImpl=replicatePutsViaCopy=true,replicateUpdatesViaCopy=true
depending on how you want your custom cache to behave. If a value is not specified in the above property, it falls back to constants specifed in PortalCacheReplicator.java.
2./ point to override-liferay-multi-vm-clustered.xml in portal-ext.properties:
ehcache.multi.vm.config.location=/myehcache/override-liferay-multi-vm-clustered.xml
via relative path, relative to WEB-INF/classes as an absolute path is not accepted. In the example above, the xml is placed in WEB-INF/classes/myehcache folder.
3./ create the override-liferay-multi-vm-clustered.xml: extract liferay-multi-vm-clustered.xml from com.liferay.portal.cache.ehcache.impl.jar located in /osgi/marketplace/Liferay Foundation - Liferay Portal Cache - Impl.lpkg in DXP 7.1, or from com.liferay.portal.cache.ehcache.jar located in /osgi/marketplace/Liferay Foundation.lpkg in DXP 7.0, and rename the file to override-liferay-multi-vm-clustered.xml. Append your custom cache configuration at the end of the file before the </ehcache> tag.
4./ place the override-liferay-multi-vm-clustered.xml on classpath (in WEB-INF/classes or its subfolder). In the example above, to WEB-INF/classes/myehcache folder)
5./ start the Portal.