-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: strange non repeatable NullPointerException
PostPosted: Thu Jan 15, 2004 9:50 pm 
Newbie

Joined: Fri Dec 05, 2003 12:44 am
Posts: 16
Hello,

I'm occasionally getting the following NPE exception when I try to load an object. Also, strangely, if I do the same load directly after one that caused an exception the second load will always be successful.

Any clues about what could be causing this?

I'm using Spring to manage transactions/session.

Code:
java.lang.NullPointerException
   at net.sf.hibernate.collection.PersistentCollection.forceInitialization(PersistentCollection.java:331)
   at net.sf.hibernate.impl.SessionImpl.initializeNonLazyCollections(SessionImpl.java:3007)
   at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:137)
   at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:830)
   at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:850)
   at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:57)
   at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:49)
   at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:420)
   at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2044)
   at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1918)
   at net.sf.hibernate.impl.SessionImpl.load(SessionImpl.java:1847)
   at ourcommunity.util.hibernate.HibernateHelper$1.doInHibernate(HibernateHelper.java:49)
   at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:147)
   at ourcommunity.util.hibernate.HibernateHelper.get(HibernateHelper.java:44)
   at ourcommunity.newsletter.dao.NewsletterDAO.findEditionVariation(NewsletterDAO.java:67)
   .
   .
   .


Mapping is this

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
    PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
    <class name="ourcommunity.newsletter.dao.EditionVariationDO" table="NewsletterEditionVariation"             
            select-before-update="true"
            dynamic-update="true">

        <cache usage="read-write" />
   
        <id name="id" type="int" column="ID" unsaved-value="0" >
            <generator class="identity"/>
        </id>
       
        <version name="version" />

        <property name="status" column="Status" />
   <property name="variation" column="Variation" />
   <property name="deliveryOption" column="DeliveryOption" />
   <property name="bulkEmailId" column="BulkEmailID" />
   <property name="editionId" column="NewsletterEditionID" />
    </class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 6:28 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hum, that's strange, it seems that the session associated to this collection was closed. Does it sounds familiar in your app ?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 6:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Actually it seems like the collection does not have a reference to any session. How did this come about? Something to do with serialization?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 18, 2004 7:00 pm 
Newbie

Joined: Fri Dec 05, 2003 12:44 am
Posts: 16
Tracked this one down to some silly old code left over from when I was using Castor for ORM.

In one of the setters of EditionVariationDO there was some code that manually loaded a related object. This meant that the session was getting called recursively and I'd say that really messed with some of the internal state. Obviously the recursive call was successful but it's caused problems down the line for the original call.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.