java.lang.NullPointerException

Hibernate JIRA | Eugene Goroschenya | 7 years ago
  1. 0

    NPE during inserting new audited entity with reference to another proxy entity if proxy.lazyInitializer.session is null java.lang.NullPointerException at org.hibernate.envers.tools.Tools.getTargetFromProxy(Tools.java:74) at org.hibernate.envers.event.AuditEventListener.generateBidirectionalCollectionChangeWorkUnits(AuditEventListener.java:108) at org.hibernate.envers.event.AuditEventListener.onPostInsert(AuditEventListener.java:152) at org.hibernate.action.EntityIdentityInsertAction.postInsert(EntityIdentityInsertAction.java:113) at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:89) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:321) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93) at com.jcatalog.core.persistence.hibernate.HibernateSaveOrUpdateListener.onSaveOrUpdate(HibernateSaveOrUpdateListener.java:31) at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:535) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:527) at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:241) at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:292) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:240) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:193) at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:320) at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:266) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:243) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:193) at org.hibernate.engine.Cascade.cascade(Cascade.java:154) at org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:479) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:357) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93) at com.jcatalog.core.persistence.hibernate.HibernateSaveOrUpdateListener.onSaveOrUpdate(HibernateSaveOrUpdateListener.java:31) at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:535) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:527) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:523) at org.springframework.orm.hibernate3.HibernateTemplate$16.doInHibernate(HibernateTemplate.java:747) at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419) at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374) at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:744) at com.jcatalog.jsfeditor.facade.HibernateEditorFacade.save(HibernateEditorFacade.java:33) It seems It happens when hibernate session was cleared so proxy.lazyInitializer.session is set to null but this object can be used later as refernce in other entity. Just for information such use case works OK with hibernate without Envers as far as we not try call getters of proxy with null session.

    Hibernate JIRA | 7 years ago | Eugene Goroschenya
    java.lang.NullPointerException
  2. 0

    NPE during inserting new audited entity with reference to another proxy entity if proxy.lazyInitializer.session is null java.lang.NullPointerException at org.hibernate.envers.tools.Tools.getTargetFromProxy(Tools.java:74) at org.hibernate.envers.event.AuditEventListener.generateBidirectionalCollectionChangeWorkUnits(AuditEventListener.java:108) at org.hibernate.envers.event.AuditEventListener.onPostInsert(AuditEventListener.java:152) at org.hibernate.action.EntityIdentityInsertAction.postInsert(EntityIdentityInsertAction.java:113) at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:89) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:321) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93) at com.jcatalog.core.persistence.hibernate.HibernateSaveOrUpdateListener.onSaveOrUpdate(HibernateSaveOrUpdateListener.java:31) at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:535) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:527) at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:241) at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:292) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:240) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:193) at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:320) at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:266) at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:243) at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:193) at org.hibernate.engine.Cascade.cascade(Cascade.java:154) at org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:479) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:357) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93) at com.jcatalog.core.persistence.hibernate.HibernateSaveOrUpdateListener.onSaveOrUpdate(HibernateSaveOrUpdateListener.java:31) at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:535) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:527) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:523) at org.springframework.orm.hibernate3.HibernateTemplate$16.doInHibernate(HibernateTemplate.java:747) at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419) at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374) at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:744) at com.jcatalog.jsfeditor.facade.HibernateEditorFacade.save(HibernateEditorFacade.java:33) It seems It happens when hibernate session was cleared so proxy.lazyInitializer.session is set to null but this object can be used later as refernce in other entity. Just for information such use case works OK with hibernate without Envers as far as we not try call getters of proxy with null session.

    Hibernate JIRA | 7 years ago | Eugene Goroschenya
    java.lang.NullPointerException
  3. 0

    Android: Saving Map State in Google map

    Stack Overflow | 11 months ago | Junie Negentien
    java.lang.RuntimeException: Unable to resume activity {com.ourThesis.junieNegentien2015/com.ourThesis.junieNegentien2015.MainActivity}: java.lang.NullPointerException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

    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 org.hibernate.envers.tools.Tools.getTargetFromProxy()
    2. A Hibernate O/RM Module
      AuditEventListener.onPostInsert
      1. org.hibernate.envers.tools.Tools.getTargetFromProxy(Tools.java:74)
      2. org.hibernate.envers.event.AuditEventListener.generateBidirectionalCollectionChangeWorkUnits(AuditEventListener.java:108)
      3. org.hibernate.envers.event.AuditEventListener.onPostInsert(AuditEventListener.java:152)
      3 frames
    3. Hibernate
      EntityIdentityInsertAction.execute
      1. org.hibernate.action.EntityIdentityInsertAction.postInsert(EntityIdentityInsertAction.java:113)
      2. org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:89)
      2 frames
    4. Hibernate
      ActionQueue.execute
      1. org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
      1 frame
    5. Hibernate
      DefaultSaveOrUpdateEventListener.onSaveOrUpdate
      1. org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:321)
      2. org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
      3. org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130)
      4. org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
      5. org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
      6. org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117)
      7. org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
      7 frames
    6. com.jcatalog.core
      HibernateSaveOrUpdateListener.onSaveOrUpdate
      1. com.jcatalog.core.persistence.hibernate.HibernateSaveOrUpdateListener.onSaveOrUpdate(HibernateSaveOrUpdateListener.java:31)
      1 frame
    7. Hibernate
      SessionImpl.saveOrUpdate
      1. org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:535)
      2. org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:527)
      2 frames
    8. Hibernate
      Cascade.cascade
      1. org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:241)
      2. org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:292)
      3. org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:240)
      4. org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:193)
      5. org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:320)
      6. org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:266)
      7. org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:243)
      8. org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:193)
      9. org.hibernate.engine.Cascade.cascade(Cascade.java:154)
      9 frames
    9. Hibernate
      DefaultSaveOrUpdateEventListener.onSaveOrUpdate
      1. org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:479)
      2. org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:357)
      3. org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
      4. org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130)
      5. org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
      6. org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
      7. org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117)
      8. org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
      8 frames
    10. com.jcatalog.core
      HibernateSaveOrUpdateListener.onSaveOrUpdate
      1. com.jcatalog.core.persistence.hibernate.HibernateSaveOrUpdateListener.onSaveOrUpdate(HibernateSaveOrUpdateListener.java:31)
      1 frame
    11. Hibernate
      SessionImpl.saveOrUpdate
      1. org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:535)
      2. org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:527)
      3. org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:523)
      3 frames
    12. Hibernate
      HibernateTemplate.saveOrUpdate
      1. org.springframework.orm.hibernate3.HibernateTemplate$16.doInHibernate(HibernateTemplate.java:747)
      2. org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
      3. org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
      4. org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:744)
      4 frames
    13. com.jcatalog.jsfeditor
      HibernateEditorFacade.save
      1. com.jcatalog.jsfeditor.facade.HibernateEditorFacade.save(HibernateEditorFacade.java:33)
      1 frame