java.lang.NullPointerException

Hibernate JIRA | Mindaugas Žakšauskas | 5 years ago
  1. 0

    This is a spin-off from - https://forum.hibernate.org/viewtopic.php?f=1&t=1013687&sid=e62b8ea711e4986a6ff419e3e641e2e8 - http://stackoverflow.com/q/8404559/7345 org.hibernate.cache.CacheKey is an object which is used for L2 cache notifications - e.g. to flush a cache on a different cluster node when a certain object has been updated. The problem comes from org.hibernate.cache.CacheKey carrying the type which (sometimes) happens to have a reference to objects like org.hibernate.impl.SessionFactoryImpl. This problem is actually not just theoretic but also causes real pain. First, it takes much longer to broadcast cache flush events. Secondly, I get this exception during deserialization of such a CacheKey: java.lang.NullPointerException at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:768) at org.hibernate.impl.SessionFactoryObjectFactory.getNamedInstance(SessionFactoryObjectFactory.java:159) at org.hibernate.impl.SessionFactoryImpl.readResolve(SessionFactoryImpl.java:753) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:1061) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1762) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.readUnshared(ObjectInputStream.java:441) at my.class.deserializeKey(EhcacheUtils.java:35) I have done a quick scan through all the types, and found these problems related to their serializability: 1) org.hibernate.type.CollectionType, org.hibernate.type.ComponentType and subclasses of both - they use attribute "typeScope" (of type TypeFactory.TypeScope) which is assigned in the constructor and kept in the but seems to be never used. The typeScope in turn has a reference to the SessionImpl. Can it simply be removed? 2) org.hibernate.type.EntityType (and its subclasses) stores typeScope and only uses it in the getter, so I guess it should be safe to remove it, too. 3) org.hibernate.type.SortedSetType and org.hibernate.type.SortedMapType keeps a reference to the comparator, but does not enforce its serializability. It should at least throw a runtime exception in org.hibernate.mapping.Collection::getComparator if the comparator is not serializable.

    Hibernate JIRA | 5 years ago | Mindaugas Žakšauskas
    java.lang.NullPointerException
  2. 0

    This is a spin-off from - https://forum.hibernate.org/viewtopic.php?f=1&t=1013687&sid=e62b8ea711e4986a6ff419e3e641e2e8 - http://stackoverflow.com/q/8404559/7345 org.hibernate.cache.CacheKey is an object which is used for L2 cache notifications - e.g. to flush a cache on a different cluster node when a certain object has been updated. The problem comes from org.hibernate.cache.CacheKey carrying the type which (sometimes) happens to have a reference to objects like org.hibernate.impl.SessionFactoryImpl. This problem is actually not just theoretic but also causes real pain. First, it takes much longer to broadcast cache flush events. Secondly, I get this exception during deserialization of such a CacheKey: java.lang.NullPointerException at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:768) at org.hibernate.impl.SessionFactoryObjectFactory.getNamedInstance(SessionFactoryObjectFactory.java:159) at org.hibernate.impl.SessionFactoryImpl.readResolve(SessionFactoryImpl.java:753) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:1061) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1762) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.readUnshared(ObjectInputStream.java:441) at my.class.deserializeKey(EhcacheUtils.java:35) I have done a quick scan through all the types, and found these problems related to their serializability: 1) org.hibernate.type.CollectionType, org.hibernate.type.ComponentType and subclasses of both - they use attribute "typeScope" (of type TypeFactory.TypeScope) which is assigned in the constructor and kept in the but seems to be never used. The typeScope in turn has a reference to the SessionImpl. Can it simply be removed? 2) org.hibernate.type.EntityType (and its subclasses) stores typeScope and only uses it in the getter, so I guess it should be safe to remove it, too. 3) org.hibernate.type.SortedSetType and org.hibernate.type.SortedMapType keeps a reference to the comparator, but does not enforce its serializability. It should at least throw a runtime exception in org.hibernate.mapping.Collection::getComparator if the comparator is not serializable.

    Hibernate JIRA | 5 years ago | Mindaugas Žakšauskas
    java.lang.NullPointerException
  3. 0

    http://forums.terracotta.org/forums/posts/list/7678.page#37323. I have requested for more details about the complete Terracotta Server and Client logs from the date and time of the incident. Root exception is: net.sf.ehcache.CacheException: java.lang.NullPointerException at org.terracotta.modules.ehcache.store.ValueModeHandlerSerialization.getRealKeyObject(ValueModeHandlerSerialization.java:128) at org.terracotta.modules.ehcache.store.ValueModeHandlerSoftLockAwareSerialization.getRealKeyObject(ValueModeHandlerSoftLockAwareSerialization.java:68) at org.terracotta.modules.ehcache.store.ClusteredStoreBackendImpl$TDCWithEvents.onEvict(ClusteredStoreBackendImpl.java:204) at org.terracotta.cache.TerracottaDistributedCache.evicted(TerracottaDistributedCache.java:447) at com.terracotta.toolkit.collections.ConcurrentDistributedServerMapDso.notifyElementEvicted(ConcurrentDistributedServerMapDso.java:436) at com.terracotta.toolkit.collections.ConcurrentDistributedServerMapDso.evictedInServer(ConcurrentDistributedServerMapDso.java:425) at com.tc.object.handler.ReceiveServerMapEvictionBroadcastHandler.handleEvent(ReceiveServerMapEvictionBroadcastHandler.java:39) at com.tc.async.impl.StageImpl$WorkerThread.run(StageImpl.java:135) Caused by: java.lang.NullPointerException at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:768) at org.hibernate.impl.SessionFactoryObjectFactory.getNamedInstance(SessionFactoryObjectFactory.java:159) at org.hibernate.impl.SessionFactoryImpl.readResolve(SessionFactoryImpl.java:753) at sun.reflect.GeneratedMethodAccessor616.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:1061)

    Terracotta Project Issue Tracker | 4 years ago | Karthik Lalithraj
    net.sf.ehcache.CacheException: java.lang.NullPointerException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    http://forums.terracotta.org/forums/posts/list/7678.page#37323. I have requested for more details about the complete Terracotta Server and Client logs from the date and time of the incident. Root exception is: net.sf.ehcache.CacheException: java.lang.NullPointerException at org.terracotta.modules.ehcache.store.ValueModeHandlerSerialization.getRealKeyObject(ValueModeHandlerSerialization.java:128) at org.terracotta.modules.ehcache.store.ValueModeHandlerSoftLockAwareSerialization.getRealKeyObject(ValueModeHandlerSoftLockAwareSerialization.java:68) at org.terracotta.modules.ehcache.store.ClusteredStoreBackendImpl$TDCWithEvents.onEvict(ClusteredStoreBackendImpl.java:204) at org.terracotta.cache.TerracottaDistributedCache.evicted(TerracottaDistributedCache.java:447) at com.terracotta.toolkit.collections.ConcurrentDistributedServerMapDso.notifyElementEvicted(ConcurrentDistributedServerMapDso.java:436) at com.terracotta.toolkit.collections.ConcurrentDistributedServerMapDso.evictedInServer(ConcurrentDistributedServerMapDso.java:425) at com.tc.object.handler.ReceiveServerMapEvictionBroadcastHandler.handleEvent(ReceiveServerMapEvictionBroadcastHandler.java:39) at com.tc.async.impl.StageImpl$WorkerThread.run(StageImpl.java:135) Caused by: java.lang.NullPointerException at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:768) at org.hibernate.impl.SessionFactoryObjectFactory.getNamedInstance(SessionFactoryObjectFactory.java:159) at org.hibernate.impl.SessionFactoryImpl.readResolve(SessionFactoryImpl.java:753) at sun.reflect.GeneratedMethodAccessor616.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:1061)

    Terracotta Project Issue Tracker | 4 years ago | Karthik Lalithraj
    net.sf.ehcache.CacheException: java.lang.NullPointerException

  1. Hronom 201 times, last 4 weeks ago
8 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.lang.NullPointerException

    No message provided

    at java.util.concurrent.ConcurrentHashMap.get()
  2. Java RT
    ConcurrentHashMap.get
    1. java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:768)
    1 frame
  3. Hibernate
    SessionFactoryImpl.readResolve
    1. org.hibernate.impl.SessionFactoryObjectFactory.getNamedInstance(SessionFactoryObjectFactory.java:159)
    2. org.hibernate.impl.SessionFactoryImpl.readResolve(SessionFactoryImpl.java:753)
    2 frames
  4. Java RT
    ObjectInputStream.readUnshared
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    4. java.lang.reflect.Method.invoke(Method.java:597)
    5. java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:1061)
    6. java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1762)
    7. java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    8. java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
    9. java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
    10. java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
    11. java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    12. java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
    13. java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
    14. java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
    15. java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    16. java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
    17. java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
    18. java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
    19. java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    20. java.io.ObjectInputStream.readUnshared(ObjectInputStream.java:441)
    20 frames
  5. my
    class.deserializeKey
    1. my.class.deserializeKey(EhcacheUtils.java:35)
    1 frame