Cache refresh is showing error with @cacheable annotation

561 views
Skip to first unread message

Kesha Shah

unread,
Mar 11, 2015, 5:38:53 AM3/11/15
to ehcache-sprin...@googlegroups.com
Hi all,

Can someone help me to debug this error ?


2015-03-11 14:59:03,844 [cachename.data] ERROR n.s.e.store.disk.DiskStorageFactory - Disk Write of -351643849550012 failed: 
java.io.NotSerializableException: com.googlecode.ehcache.annotations.RefreshableCacheEntry
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164) ~[na:1.6.0_45]
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518) ~[na:1.6.0_45]
at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:422) ~[na:1.6.0_45]
at net.sf.ehcache.Element.writeObject(Element.java:867) ~[ehcache-2.8.1.jar:2.8.1]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[na:1.6.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_45]
at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_45]
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:940) ~[na:1.6.0_45]
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1469) ~[na:1.6.0_45]
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400) ~[na:1.6.0_45]
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158) ~[na:1.6.0_45]
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330) ~[na:1.6.0_45]
at net.sf.ehcache.util.MemoryEfficientByteArrayOutputStream.serialize(MemoryEfficientByteArrayOutputStream.java:97) ~[ehcache-2.8.1.jar:2.8.1]
at net.sf.ehcache.store.disk.DiskStorageFactory.serializeElement(DiskStorageFactory.java:399) ~[ehcache-2.8.1.jar:2.8.1]
at net.sf.ehcache.store.disk.DiskStorageFactory.write(DiskStorageFactory.java:381) ~[ehcache-2.8.1.jar:2.8.1]
at net.sf.ehcache.store.disk.DiskStorageFactory$DiskWriteTask.call(DiskStorageFactory.java:473) ~[ehcache-2.8.1.jar:2.8.1]
at net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1067) [ehcache-2.8.1.jar:2.8.1]
at net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1051) [ehcache-2.8.1.jar:2.8.1]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [na:1.6.0_45]
at java.util.concurrent.FutureTask.run(FutureTask.java:138) [na:1.6.0_45]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98) [na:1.6.0_45]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206) [na:1.6.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) [na:1.6.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) [na:1.6.0_45]
at java.lang.Thread.run(Thread.java:662) [na:1.6.0_45]

I am using cache refresh with @cacheable annotation:

CacheFetchDao.java 


@Cacheable(cacheName = "cachename",refreshInterval=10000, decoratedCacheType= DecoratedCacheType.REFRESHING_SELF_POPULATING_CACHE)
//@Cacheable( value = "cachename", key = "#key")
public List<Account> getAccounts(String key) {
//call to database
return res;
}


CachefetchEndpoint.java
        @GET
@Path("/Accounts")
@WebMethod(operationName = "Accounts")
public List<Account> Accounts() {
return dao.getAccounts("accounts");
}

ehcache.xml

xsi:noNamespaceSchemaLocation="ehcache.xsd" 
updateCheck="true"
monitoring="autodetect" 
dynamicConfig="true">
 
    <diskStore path="java.io.tmpdir"/>  
    
    <defaultCache    
        maxElementsInMemory="100"  
        eternal="false"    
        timeToIdleSeconds="120"    
        timeToLiveSeconds="120"    
        overflowToDisk="true"    
        diskSpoolBufferSizeMB="30"    
        maxElementsOnDisk="10000000"    
        diskPersistent="false"    
        diskExpiryThreadIntervalSeconds="120"    
        memoryStoreEvictionPolicy="LRU"/>  
  
    <!-- The cache configuration for our Currency cache -->  
    <cache name="cachename"  
        maxElementsInMemory="3000"  
        eternal="false" 
        timeToIdleSeconds="120"  
        timeToLiveSeconds="120"  
        <persistence strategy="localTempSwap"/>
    </cache>  
</ehcache>  

and config.xml

 <ehcache:annotation-driven cache-manager="ehcache" />
    
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="ehcache" />
</bean>
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" >
<property name="configLocation" value="ehcache.xml" />
</bean>  


Thanks !

Regards,
Kesha Shah  

Eric Dalquist

unread,
Mar 11, 2015, 10:56:35 AM3/11/15
to ehcache-sprin...@googlegroups.com
refreshable cache annotations can't be used with persistent or replicated caches.

--
You received this message because you are subscribed to the Google Groups "Ehcache Spring Annotations" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ehcache-spring-anno...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kesha Shah

unread,
Mar 11, 2015, 6:02:57 PM3/11/15
to ehcache-sprin...@googlegroups.com, eric.d...@gmail.com
Hi Eric,

Thanks. But can you please elaborate a little as to why is that condition imposed by spring ? I am not able to catch the rationale behind it.

My requirement is multiple clients would be calling cachefetchendpoint.java and I don't want any client to wait while the cache is being refreshed. I am ok to send them a stale data (expired data).

So for that I think I would need a local persistant copy of the old cache to be returned when the UI is trying to access the cache which is currently being refreshed from database, right ?

Regards,

--
You received this message because you are subscribed to a topic in the Google Groups "Ehcache Spring Annotations" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ehcache-spring-annotations/pokFxkrWC0Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ehcache-spring-anno...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Kesha Shah.

Ella Baila Sola

unread,
Mar 13, 2015, 12:33:22 PM3/13/15
to ehcache-sprin...@googlegroups.com

Google code is being shutdown

Reply all
Reply to author
Forward
0 new messages