• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NullPointerException in hibernate PersistentBag.getSnapshot()

 
lastranchie tiwari
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am getting a NullPointerException in a hibernate API.

Trace of the exception is -

com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor
java.lang.NullPointerException
at org.hibernate.collection.PersistentBag.getSnapshot(PersistentBag.java:132)
at org.hibernate.engine.CollectionEntry.postInitialize(CollectionEntry.java:214)
at org.hibernate.engine.StatefulPersistenceContext.addInitializedCollection(StatefulPersistenceContext.java:833)
at org.hibernate.engine.loading.CollectionLoadContext.endLoadingCollection(CollectionLoadContext.java:268)
at org.hibernate.engine.loading.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:245)
at org.hibernate.engine.loading.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:218)
at org.hibernate.loader.Loader.endCollectionLoad(Loader.java:900)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:888)
at org.hibernate.loader.Loader.doQuery(Loader.java:752)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.loadCollection(Loader.java:2015)
at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:59)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:587)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:83)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1743)
at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:476)
at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:867)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:264)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1881)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:71)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:65)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3072)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:434)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:415)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:165)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:223)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:126)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:905)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:842)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:835)
at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:182)
...................

Jars used in the project are - hibernate-core 3.3.0.SP1.jar and Spring 2.5.6.SEC01.jar
I looked at the code of PersistentBag, and found out that the nullPointer was at line -

This means that session would have been null.
But in my code i see nowhere, where i have closed a session, before this exception is encountered.

Please help with this issue.
Any suggestions would be appreciated.

Thanks.
 
Vijitha Kumara
Bartender
Pie
Posts: 3930
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
..But in my code i see nowhere, where i have closed a session...

Are you able to perform other database operations before this executed? Just do a simple "SELECT ..." and try whether it works first.

And are you able to successfully initialize Hibernate in the first place? There need to be more jar files (from Hibernate itself as mandatory) available for Hibernate to work...(check the readme file in the Hibernate distro).
 
lastranchie tiwari
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Vijitha,

Thanks for the reply.
Are you able to perform other database operations before this executed? Just do a simple "SELECT ..." and try whether it works first.

About this, yes i am able to do all sorts of DB operations before this.

And are you able to successfully initialize Hibernate in the first place? There need to be more jar files (from Hibernate itself as mandatory) available for Hibernate to work

This thing is not a problem, because this exception is not a regular one. Most of the time everything works fine. It is just once in a few days this happens.

I am still clueless about this exception.

Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic