java.io.NotSerializableException: net.sf.ehcache.Cache

Apereo Issues | Jaroslav Kacer | 2 years ago
  1. 0

    EhCache-based ticket cache - Errors when storing tickets to disk

    GitHub | 2 years ago | jkacer
    java.io.NotSerializableException: net.sf.ehcache.Cache
  2. 0

    [cas-user] CAS 4 + EhCache-based ticket cache - Errors when storing tickets to disk

    Google Groups | 2 years ago | Jaroslav Kacer
    java.io.NotSerializableException: net.sf.ehcache.Cache
  3. 0

    I use CAS 4.0.0 in a cluster of 2 nodes. I configured the ticket registry using EhCache, as described here: http://jasig.github.io/cas/4.0.0/installation/Ehcache-Ticket-Registry.html I have disk overflow set to true: {noformat} <bean id="abstractTicketCache" abstract="true" class="org.springframework.cache.ehcache.EhCacheFactoryBean" p:cacheManager-ref="cacheManager" p:diskExpiryThreadIntervalSeconds="0" p:diskPersistent="false" p:eternal="false" p:maxElementsInMemory="10000" p:maxElementsOnDisk="20000" p:memoryStoreEvictionPolicy="LRU" p:overflowToDisk="true" p:bootstrapCacheLoader-ref="ticketCacheBootstrapCacheLoader" /> <bean id="serviceTicketsCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean" parent="abstractTicketCache" p:cacheName="cas_st" p:timeToIdle="0" p:timeToLive="300" p:cacheEventListeners-ref="serviceTicketRMISynchronousCacheReplicator" /> {noformat} My problem is that from time to time, I get an error when the ticket registry decides to save tickets (STs or TGTs) to disk. An exception is logged in the log, saying that net.sf.ehcache.Cache is not serializable (which is true). Here is an example of the exception: {noformat} 2014-10-09 10:18:59,266 ERROR [net.sf.ehcache.store.disk.DiskStorageFactory] - <Disk Write of ST-18-sE417I7BTdfhABdhRMNQ-idc-cas-4 failed: > java.io.NotSerializableException: net.sf.ehcache.Cache at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1180) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528) at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:438) at net.sf.ehcache.Element.writeObject(Element.java:851) at sun.reflect.GeneratedMethodAccessor138.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:975) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346) at net.sf.ehcache.util.MemoryEfficientByteArrayOutputStream.serialize(MemoryEfficientByteArrayOutputStream.java:97) at net.sf.ehcache.store.disk.DiskStorageFactory.serializeElement(DiskStorageFactory.java:399) at net.sf.ehcache.store.disk.DiskStorageFactory.write(DiskStorageFactory.java:381) at net.sf.ehcache.store.disk.DiskStorageFactory$DiskWriteTask.call(DiskStorageFactory.java:473) at net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1067) at net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1051) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:722) {noformat} It seems that CAS tickets indirectly reference the cache which causes Java runtime to try to serialize it too. Unfortunately I haven’t found the path from tickets to caches yet. A quick workaround is to set disk overflow to false. Then the error does not appear. However, it still appears at different places, e.g. at application shutdown. I will attach a log file showing stacktraces during shutdown. It would be great if someone could have a look at it.

    Apereo Issues | 2 years ago | Jaroslav Kacer
    java.io.NotSerializableException: net.sf.ehcache.Cache
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    I use CAS 4.0.0 in a cluster of 2 nodes. I configured the ticket registry using EhCache, as described here: http://jasig.github.io/cas/4.0.0/installation/Ehcache-Ticket-Registry.html I have disk overflow set to true: {noformat} <bean id="abstractTicketCache" abstract="true" class="org.springframework.cache.ehcache.EhCacheFactoryBean" p:cacheManager-ref="cacheManager" p:diskExpiryThreadIntervalSeconds="0" p:diskPersistent="false" p:eternal="false" p:maxElementsInMemory="10000" p:maxElementsOnDisk="20000" p:memoryStoreEvictionPolicy="LRU" p:overflowToDisk="true" p:bootstrapCacheLoader-ref="ticketCacheBootstrapCacheLoader" /> <bean id="serviceTicketsCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean" parent="abstractTicketCache" p:cacheName="cas_st" p:timeToIdle="0" p:timeToLive="300" p:cacheEventListeners-ref="serviceTicketRMISynchronousCacheReplicator" /> {noformat} My problem is that from time to time, I get an error when the ticket registry decides to save tickets (STs or TGTs) to disk. An exception is logged in the log, saying that net.sf.ehcache.Cache is not serializable (which is true). Here is an example of the exception: {noformat} 2014-10-09 10:18:59,266 ERROR [net.sf.ehcache.store.disk.DiskStorageFactory] - <Disk Write of ST-18-sE417I7BTdfhABdhRMNQ-idc-cas-4 failed: > java.io.NotSerializableException: net.sf.ehcache.Cache at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1180) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528) at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:438) at net.sf.ehcache.Element.writeObject(Element.java:851) at sun.reflect.GeneratedMethodAccessor138.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:975) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346) at net.sf.ehcache.util.MemoryEfficientByteArrayOutputStream.serialize(MemoryEfficientByteArrayOutputStream.java:97) at net.sf.ehcache.store.disk.DiskStorageFactory.serializeElement(DiskStorageFactory.java:399) at net.sf.ehcache.store.disk.DiskStorageFactory.write(DiskStorageFactory.java:381) at net.sf.ehcache.store.disk.DiskStorageFactory$DiskWriteTask.call(DiskStorageFactory.java:473) at net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1067) at net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1051) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:722) {noformat} It seems that CAS tickets indirectly reference the cache which causes Java runtime to try to serialize it too. Unfortunately I haven’t found the path from tickets to caches yet. A quick workaround is to set disk overflow to false. Then the error does not appear. However, it still appears at different places, e.g. at application shutdown. I will attach a log file showing stacktraces during shutdown. It would be great if someone could have a look at it.

    Apereo Issues | 2 years ago | Jaroslav Kacer
    java.io.NotSerializableException: net.sf.ehcache.Cache
  6. 0

    ehcache memory only cache attempting to store to disk

    Stack Overflow | 3 years ago | Collin Peters
    java.io.NotSerializableException: intouch.connector.business.LeadSourceCollection

  1. Malcshour 68 times, last 7 months ago
12 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.io.NotSerializableException

    net.sf.ehcache.Cache

    at java.io.ObjectOutputStream.writeObject0()
  2. Java RT
    ObjectOutputStream.defaultWriteObject
    1. java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1180)
    2. java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
    3. java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
    4. java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
    5. java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
    6. java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
    7. java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
    8. java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
    9. java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
    10. java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
    11. java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:438)
    11 frames
  3. Ehcache
    Element.writeObject
    1. net.sf.ehcache.Element.writeObject(Element.java:851)
    1 frame
  4. Java RT
    ObjectOutputStream.writeObject
    1. sun.reflect.GeneratedMethodAccessor138.invoke(Unknown Source)
    2. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    3. java.lang.reflect.Method.invoke(Method.java:601)
    4. java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:975)
    5. java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
    6. java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
    7. java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
    8. java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
    8 frames
  5. Ehcache
    DiskStorageFactory$PersistentDiskWriteTask.call
    1. net.sf.ehcache.util.MemoryEfficientByteArrayOutputStream.serialize(MemoryEfficientByteArrayOutputStream.java:97)
    2. net.sf.ehcache.store.disk.DiskStorageFactory.serializeElement(DiskStorageFactory.java:399)
    3. net.sf.ehcache.store.disk.DiskStorageFactory.write(DiskStorageFactory.java:381)
    4. net.sf.ehcache.store.disk.DiskStorageFactory$DiskWriteTask.call(DiskStorageFactory.java:473)
    5. net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1067)
    6. net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1051)
    6 frames
  6. Java RT
    Thread.run
    1. java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    2. java.util.concurrent.FutureTask.run(FutureTask.java:166)
    3. java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
    4. java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
    5. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    6. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    7. java.lang.Thread.run(Thread.java:722)
    7 frames