Batch Admin SimpleEhCacheInterceptor Configuration overriding ehcache.xml settings
We've got a spring batch deployment (using Batch Admin) and we've run into an issue where our application's ehcache.xml config is not being respected when the AnnotationSessionFactoryBean bootstraps Hibernate. We traced it to the fact that SimpleEhCacheInterceptor invokes CacheManager.create(config ) to create an unnamed manager and uses the failsafe configuration. As a result all of our cached entities are now overflowing to disk, which is something we don't want.
Code:
public void afterPropertiesSet() throws Exception {
Configuration config = ConfigurationFactory.parseConfiguration();
config.setUpdateCheck(false);
manager = CacheManager.create(config );
cache = new Cache(name, 0, true, false, timeout, 0);
manager.addCache(cache);
}
We were able to fix this by amending our ehcache.xml file to include a cache manager name in the top element:
Code:
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd"
updateCheck="true" name="myCacheManager">
It seems like it would be somewhat better if the CacheManager SimpleEhCacheInterceptor would name itself so that it didn't supersede whatever default cache manager was used by the spring context that actually contained the job implementations.
Has anyone else run into this or does everyone just work with names configured into their ehcache.xml configs?
I also have the same problem did somebody knows how to solve it?
Quote:
Originally Posted by
lubo
I still have a problem, this is what I see during Tomcat start-up:
WARN : net.sf.ehcache.config.CacheConfiguration - Cache: simple has a maxElementsInMemory of 0. This might lead to performance degradation or OutOfMemoryError at Terracotta client.From Ehcache 2.0 onwards this has been changed to mean a store with no capacity limit. Set it to 1 if you want no elements cached in memory
ERROR: net.sf.ehcache.store.disk.DiskStorageFactory - Disk Write of listJobs[0, 2147483647] failed:
java.io.NotSerializableException: java.util.RandomAccessSubList
at java.io.ObjectOutputStream.writeObject0(ObjectOutp utStream.java:1164)
at java.io.ObjectOutputStream.defaultWriteFields(Obje ctOutputStream.java:1518)
at java.io.ObjectOutputStream.defaultWriteObject(Obje ctOutputStream.java:422)
at net.sf.ehcache.Element.writeObject(Element.java:79 7)
My stack trace is more or less the same:
2:14:13,220 ERROR simple.data disk.DiskStorageFactory:495 - Disk Write of listJobs[0, 2147483647] failed:
java.io.NotSerializableException: java.util.RandomAccessSubList
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.defaultWriteFields(Unkn own Source)
at java.io.ObjectOutputStream.defaultWriteObject(Unkn own Source)
at net.sf.ehcache.Element.writeObject(Element.java:83 5)
...
but the result is the same
Before this Error I see in the console the following warning:
12:14:12,674 WARN Thread-2 config.CacheConfiguration:1697 - Cache: simple has a maxElementsInMemory of 0. This might lead to performance degradation or OutOfMemoryError at Terracotta client.From Ehcache 2.0 onwards this has been changed to mean a store with no capacity limit. Set it to 1 if you want no elements cached in memory
1st Question:
How to override the maxElementsInMemory configuration and set it to 1 ?
2nd Question:
how to get rid of "Disk Write of listJobs[0, 2147483647] failed:" error?
Thank you for any suggestion
Franco