Results 1 to 3 of 3

Thread: Batch Admin SimpleEhCacheInterceptor Configuration overriding ehcache.xml settings

  1. #1

    Default 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?

  2. #2
    Join Date
    Nov 2011
    Posts
    3

    Default

    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)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at java.io.ObjectStreamClass.invokeWriteObject(Object StreamClass.java:940)
    at java.io.ObjectOutputStream.writeSerialData(ObjectO utputStream.java:1469)
    at java.io.ObjectOutputStream.writeOrdinaryObject(Obj ectOutputStream.java:1400)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutp utStream.java:1158)
    at java.io.ObjectOutputStream.writeObject(ObjectOutpu tStream.java:330)
    at net.sf.ehcache.util.MemoryEfficientByteArrayOutput Stream.serialize(MemoryEfficientByteArrayOutputStr eam.java:97)
    at net.sf.ehcache.store.disk.DiskStorageFactory.seria lizeElement(DiskStorageFactory.java:413)
    at net.sf.ehcache.store.disk.DiskStorageFactory.write (DiskStorageFactory.java:392)
    at net.sf.ehcache.store.disk.DiskStorageFactory$DiskW riteTask.call(DiskStorageFactory.java:493)
    at net.sf.ehcache.store.disk.DiskStorageFactory$Persi stentDiskWriteTask.call(DiskStorageFactory.java:11 54)
    at net.sf.ehcache.store.disk.DiskStorageFactory$Persi stentDiskWriteTask.call(DiskStorageFactory.java:11 38)
    at java.util.concurrent.FutureTask$Sync.innerRun(Futu reTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.jav a:138)
    at java.util.concurrent.ScheduledThreadPoolExecutor$S cheduledFutureTask.access$301(ScheduledThreadPoolE xecutor.java:98)
    at java.util.concurrent.ScheduledThreadPoolExecutor$S cheduledFutureTask.run(ScheduledThreadPoolExecutor .java:206)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)

  3. #3

    Default I also have the same problem did somebody knows how to solve it?

    Quote Originally Posted by lubo View Post
    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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •