java.io.NotSerializableException: java.util.HashMap$KeySet

Apereo Issues | Ammar Belakhel | 1 year ago
  1. 0

    In order to achive HA (High-Availability), I am using *EhcacheTicketRegistry* instead of the default TicketRegistry. The serialization of tickets (TGT) fails due to a non-serializable field. After investigation, I found that the bean *"authenticationMetaDataPopulators"* was uncommented in the *"deployerConfigContext.xml"* file. Actually, this bean uses a *org.jasig.cas.authentication.SuccessfulHandlerMetaDataPopulator* which tries to add the set of successful AuthenticationHandlers. Because this set is an instance of *HashMap.KeySet* (which is a non-serializable class) the serialization fails. I suggest to wrap the set successful handlers in a *HashSet* (or any serializable Set implementation) instead of a *HashMap.KeySet*. ========================================================================================== StackTrace: {code:java} java.io.NotSerializableException: java.util.HashMap$KeySet at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1183) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347) ~[?:1.7.0_60] at java.util.HashMap.writeObject(HashMap.java:1129) ~[?:1.7.0_60] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_60] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_60] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_60] at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_60] at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177) ~[?:1.7.0_60] at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1508) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177) ~[?:1.7.0_60] at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1508) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177) ~[?:1.7.0_60] at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547) ~[?:1.7.0_60] at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:440) ~[?:1.7.0_60] at net.sf.ehcache.Element.writeObject(Element.java:851) ~[ehcache-2.7.2.jar:2.7.2] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_60] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_60] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_60] at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_60] at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347) ~[?:1.7.0_60] at net.sf.ehcache.util.MemoryEfficientByteArrayOutputStream.serialize(MemoryEfficientByteArrayOutputStream.java:97) ~[ehcache-2.7.2.jar:2.7.2] at net.sf.ehcache.store.disk.DiskStorageFactory.serializeElement(DiskStorageFactory.java:399) ~[ehcache-2.7.2.jar:2.7.2] at net.sf.ehcache.store.disk.DiskStorageFactory.write(DiskStorageFactory.java:381) ~[ehcache-2.7.2.jar:2.7.2] at net.sf.ehcache.store.disk.DiskStorageFactory$DiskWriteTask.call(DiskStorageFactory.java:473) [ehcache-2.7.2.jar:2.7.2] at net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1067) [ehcache-2.7.2.jar:2.7.2] at net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1051) [ehcache-2.7.2.jar:2.7.2] at java.util.concurrent.FutureTask.run(FutureTask.java:262) [?:1.7.0_60] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178) [?:1.7.0_60] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292) [?:1.7.0_60] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.7.0_60] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.7.0_60] at java.lang.Thread.run(Thread.java:745) [?:1.7.0_60] {code}

    Apereo Issues | 1 year ago | Ammar Belakhel
    java.io.NotSerializableException: java.util.HashMap$KeySet
  2. 0

    In order to achive HA (High-Availability), I am using *EhcacheTicketRegistry* instead of the default TicketRegistry. The serialization of tickets (TGT) fails due to a non-serializable field. After investigation, I found that the bean *"authenticationMetaDataPopulators"* was uncommented in the *"deployerConfigContext.xml"* file. Actually, this bean uses a *org.jasig.cas.authentication.SuccessfulHandlerMetaDataPopulator* which tries to add the set of successful AuthenticationHandlers. Because this set is an instance of *HashMap.KeySet* (which is a non-serializable class) the serialization fails. I suggest to wrap the set successful handlers in a *HashSet* (or any serializable Set implementation) instead of a *HashMap.KeySet*. ========================================================================================== StackTrace: {code:java} java.io.NotSerializableException: java.util.HashMap$KeySet at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1183) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347) ~[?:1.7.0_60] at java.util.HashMap.writeObject(HashMap.java:1129) ~[?:1.7.0_60] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_60] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_60] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_60] at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_60] at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177) ~[?:1.7.0_60] at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1508) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177) ~[?:1.7.0_60] at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1508) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177) ~[?:1.7.0_60] at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547) ~[?:1.7.0_60] at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:440) ~[?:1.7.0_60] at net.sf.ehcache.Element.writeObject(Element.java:851) ~[ehcache-2.7.2.jar:2.7.2] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_60] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_60] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_60] at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_60] at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177) ~[?:1.7.0_60] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347) ~[?:1.7.0_60] at net.sf.ehcache.util.MemoryEfficientByteArrayOutputStream.serialize(MemoryEfficientByteArrayOutputStream.java:97) ~[ehcache-2.7.2.jar:2.7.2] at net.sf.ehcache.store.disk.DiskStorageFactory.serializeElement(DiskStorageFactory.java:399) ~[ehcache-2.7.2.jar:2.7.2] at net.sf.ehcache.store.disk.DiskStorageFactory.write(DiskStorageFactory.java:381) ~[ehcache-2.7.2.jar:2.7.2] at net.sf.ehcache.store.disk.DiskStorageFactory$DiskWriteTask.call(DiskStorageFactory.java:473) [ehcache-2.7.2.jar:2.7.2] at net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1067) [ehcache-2.7.2.jar:2.7.2] at net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1051) [ehcache-2.7.2.jar:2.7.2] at java.util.concurrent.FutureTask.run(FutureTask.java:262) [?:1.7.0_60] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178) [?:1.7.0_60] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292) [?:1.7.0_60] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.7.0_60] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.7.0_60] at java.lang.Thread.run(Thread.java:745) [?:1.7.0_60] {code}

    Apereo Issues | 1 year ago | Ammar Belakhel
    java.io.NotSerializableException: java.util.HashMap$KeySet
  3. 0

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

    GitHub | 2 years ago | jkacer
    java.io.NotSerializableException: net.sf.ehcache.Cache
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    ehcache memory only cache attempting to store to disk

    Stack Overflow | 3 years ago | Collin Peters
    java.io.NotSerializableException: intouch.connector.business.LeadSourceCollection
  6. 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

  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

    java.util.HashMap$KeySet

    at java.io.ObjectOutputStream.writeObject0()
  2. Java RT
    ObjectOutputStream.defaultWriteObject
    1. java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1183)[?:1.7.0_60]
    2. java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)[?:1.7.0_60]
    3. java.util.HashMap.writeObject(HashMap.java:1129)[?:1.7.0_60]
    4. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[?:1.7.0_60]
    5. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[?:1.7.0_60]
    6. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[?:1.7.0_60]
    7. java.lang.reflect.Method.invoke(Method.java:606)[?:1.7.0_60]
    8. java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)[?:1.7.0_60]
    9. java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495)[?:1.7.0_60]
    10. java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)[?:1.7.0_60]
    11. java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)[?:1.7.0_60]
    12. java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547)[?:1.7.0_60]
    13. java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1508)[?:1.7.0_60]
    14. java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)[?:1.7.0_60]
    15. java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)[?:1.7.0_60]
    16. java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547)[?:1.7.0_60]
    17. java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1508)[?:1.7.0_60]
    18. java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)[?:1.7.0_60]
    19. java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)[?:1.7.0_60]
    20. java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547)[?:1.7.0_60]
    21. java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:440)[?:1.7.0_60]
    21 frames
  3. Ehcache
    Element.writeObject
    1. net.sf.ehcache.Element.writeObject(Element.java:851)[ehcache-2.7.2.jar:2.7.2]
    1 frame
  4. Java RT
    ObjectOutputStream.writeObject
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[?:1.7.0_60]
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[?:1.7.0_60]
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[?:1.7.0_60]
    4. java.lang.reflect.Method.invoke(Method.java:606)[?:1.7.0_60]
    5. java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)[?:1.7.0_60]
    6. java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495)[?:1.7.0_60]
    7. java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)[?:1.7.0_60]
    8. java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)[?:1.7.0_60]
    9. java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)[?:1.7.0_60]
    9 frames
  5. Ehcache
    DiskStorageFactory$PersistentDiskWriteTask.call
    1. net.sf.ehcache.util.MemoryEfficientByteArrayOutputStream.serialize(MemoryEfficientByteArrayOutputStream.java:97)[ehcache-2.7.2.jar:2.7.2]
    2. net.sf.ehcache.store.disk.DiskStorageFactory.serializeElement(DiskStorageFactory.java:399)[ehcache-2.7.2.jar:2.7.2]
    3. net.sf.ehcache.store.disk.DiskStorageFactory.write(DiskStorageFactory.java:381)[ehcache-2.7.2.jar:2.7.2]
    4. net.sf.ehcache.store.disk.DiskStorageFactory$DiskWriteTask.call(DiskStorageFactory.java:473)[ehcache-2.7.2.jar:2.7.2]
    5. net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1067)[ehcache-2.7.2.jar:2.7.2]
    6. net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1051)[ehcache-2.7.2.jar:2.7.2]
    6 frames
  6. Java RT
    Thread.run
    1. java.util.concurrent.FutureTask.run(FutureTask.java:262)[?:1.7.0_60]
    2. java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)[?:1.7.0_60]
    3. java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)[?:1.7.0_60]
    4. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[?:1.7.0_60]
    5. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[?:1.7.0_60]
    6. java.lang.Thread.run(Thread.java:745)[?:1.7.0_60]
    6 frames