net.sf.ehcache.CacheException: The key java.lang.Object@45d6a56e is not Serializable. Consider using Element.getObjectKey()

Terracotta Project Issue Tracker | Jeferson Estevo | 2 years ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    Hello, While trying to put a non serializable key to the Cache.put method, in ehcache-core 2.6.10, we get the following exception: net.sf.ehcache.CacheException: The key java.lang.Object@45d6a56e is not Serializable. Consider using Element.getObjectKey() at net.sf.ehcache.Element.getKey(Element.java:256) at net.sf.ehcache.store.MemoryStore.evict(MemoryStore.java:853) at net.sf.ehcache.store.NotifyingMemoryStore.evict(NotifyingMemoryStore.java:60) at net.sf.ehcache.store.MemoryStore.removeElementChosenByEvictionPolicy(MemoryStore.java:596) at net.sf.ehcache.store.MemoryStore.checkCapacity(MemoryStore.java:562) at net.sf.ehcache.store.MemoryStore.put(MemoryStore.java:262) at net.sf.ehcache.store.FrontEndCacheTier.put(FrontEndCacheTier.java:267) at net.sf.ehcache.Cache.putInternal(Cache.java:1455) at net.sf.ehcache.Cache.put(Cache.java:1383) at net.sf.ehcache.Cache.put(Cache.java:1348) In version 2.6.9 it was working fine. Apparently this started happening after a change in the "NotifyingMemoryStore.evict" method in version 2.6.10. We've created this unit test so you can reproduce the scenario: @Test public void testCacheWithNonSerializableKey() { Cache cache = new Cache("test", 100, false, true, 9000, 9000, false, 900); cache.setCacheManager(new CacheManager()); cache.initialise(); cache.getCacheConfiguration().setMaxEntriesLocalHeap(1L); cache.setMemoryStoreEvictionPolicy(new LruPolicy()); for (int i = 0; i < 2; i++) { Element element = new Element(new Object(), "result"); cache.put(element); } }

    Terracotta Project Issue Tracker | 2 years ago | Jeferson Estevo
    net.sf.ehcache.CacheException: The key java.lang.Object@45d6a56e is not Serializable. Consider using Element.getObjectKey()
  2. 0

    Hello, While trying to put a non serializable key to the Cache.put method, in ehcache-core 2.6.10, we get the following exception: net.sf.ehcache.CacheException: The key java.lang.Object@45d6a56e is not Serializable. Consider using Element.getObjectKey() at net.sf.ehcache.Element.getKey(Element.java:256) at net.sf.ehcache.store.MemoryStore.evict(MemoryStore.java:853) at net.sf.ehcache.store.NotifyingMemoryStore.evict(NotifyingMemoryStore.java:60) at net.sf.ehcache.store.MemoryStore.removeElementChosenByEvictionPolicy(MemoryStore.java:596) at net.sf.ehcache.store.MemoryStore.checkCapacity(MemoryStore.java:562) at net.sf.ehcache.store.MemoryStore.put(MemoryStore.java:262) at net.sf.ehcache.store.FrontEndCacheTier.put(FrontEndCacheTier.java:267) at net.sf.ehcache.Cache.putInternal(Cache.java:1455) at net.sf.ehcache.Cache.put(Cache.java:1383) at net.sf.ehcache.Cache.put(Cache.java:1348) In version 2.6.9 it was working fine. Apparently this started happening after a change in the "NotifyingMemoryStore.evict" method in version 2.6.10. We've created this unit test so you can reproduce the scenario: @Test public void testCacheWithNonSerializableKey() { Cache cache = new Cache("test", 100, false, true, 9000, 9000, false, 900); cache.setCacheManager(new CacheManager()); cache.initialise(); cache.getCacheConfiguration().setMaxEntriesLocalHeap(1L); cache.setMemoryStoreEvictionPolicy(new LruPolicy()); for (int i = 0; i < 2; i++) { Element element = new Element(new Object(), "result"); cache.put(element); } }

    Terracotta Project Issue Tracker | 2 years ago | Jeferson Estevo
    net.sf.ehcache.CacheException: The key java.lang.Object@45d6a56e is not Serializable. Consider using Element.getObjectKey()

    Root Cause Analysis

    1. net.sf.ehcache.CacheException

      The key java.lang.Object@45d6a56e is not Serializable. Consider using Element.getObjectKey()

      at net.sf.ehcache.Element.getKey()
    2. Ehcache
      Cache.put
      1. net.sf.ehcache.Element.getKey(Element.java:256)
      2. net.sf.ehcache.store.MemoryStore.evict(MemoryStore.java:853)
      3. net.sf.ehcache.store.NotifyingMemoryStore.evict(NotifyingMemoryStore.java:60)
      4. net.sf.ehcache.store.MemoryStore.removeElementChosenByEvictionPolicy(MemoryStore.java:596)
      5. net.sf.ehcache.store.MemoryStore.checkCapacity(MemoryStore.java:562)
      6. net.sf.ehcache.store.MemoryStore.put(MemoryStore.java:262)
      7. net.sf.ehcache.store.FrontEndCacheTier.put(FrontEndCacheTier.java:267)
      8. net.sf.ehcache.Cache.putInternal(Cache.java:1455)
      9. net.sf.ehcache.Cache.put(Cache.java:1383)
      10. net.sf.ehcache.Cache.put(Cache.java:1348)
      10 frames