I'm using Castor JDO version 0.9.3.9.  When I run a query that returns a
large number of objects, I sometimes get a NullPointerException when I call
the hasMore() method on my QueryResults object.  However, other times it
works fine without any exceptions being thrown.  Here is the stack trace
from Castor that I get (starting with the call to the hasMore() method on
the QueryResults object) when I do get a NullPointerException:

2002-11-19 17:40:20,036 ERROR
com.ibm.hia.loader.model.process.UnarchivePackageFileProcess -
java.lang.NullPointerException
        at
org.exolab.castor.jdo.engine.SQLTypes.getObject(SQLTypes.java(Compiled
Code))
        at
org.exolab.castor.jdo.engine.SQLEngine$SQLQuery.loadSingleField(SQLEngine.java(Compiled

Code))
        at
org.exolab.castor.jdo.engine.SQLEngine$SQLQuery.loadRow(SQLEngine.java(Compiled

Code))
        at
org.exolab.castor.jdo.engine.SQLEngine$SQLQuery.fetchRaw(SQLEngine.java(Compiled

Code))
        at
org.exolab.castor.jdo.engine.SQLEngine$SQLQuery.nextIdentity(SQLEngine.java(Compiled

Code))
        at
org.exolab.castor.persist.QueryResults.nextIdentity(QueryResults.java(Compiled

Code))
        at
org.exolab.castor.jdo.engine.OQLQueryImpl$OQLEnumeration.hasMore(OQLQueryImpl.java(Compiled

Code))
        at
org.exolab.castor.jdo.engine.OQLQueryImpl$OQLEnumeration.hasMore(OQLQueryImpl.java(Compiled

Code))
�

I searched the archives of this mailing list, and found a solution posted
to address this problem:

http://www.mail-archive.com/[email protected]/msg07214.html

On Mon, 13 May 2002 11:03:41 +0200, Jan Ypma wrote:

Another one falling into this deeeeeep hole. :-(
It's again a bug caused by the sad finalize() method in OQLQueryImpl.java.
To get around it, try this:
in org.exolab.castor.jdo.engine.OQLQueryImpl.java
in line 519 and 706 (roughly) just comment out the finalize method.

What happens here: As soon as the QueryResults and/or the Query itself are
garbage collected (that happend REALLY soon in the hotspot engine when the
optimizer "knows" that the variable isn't used anymore...), it is closed,
hence the npe as the sql resultset is nulled on close().

I've removed these methods completely in my castor copy and have no
problems
running the server for weeks. The only part to have an eye upon is to
always
close the query or resultset properly to avoid a memory and/or sql
connection leak.


I didn't see any messages in this thread besides the original and the
reply.  I also searched for this bug in Bugzilla and didn't find anything.
Can anyone confirm that this is a Castor bug, and can anyone tell me if it
has been either addressed or will be addressed in a later version of
Castor?  Also, can anyone confirm whether or not the suggested work-around
will actually solve the problem?  I wondering why more people haven't
stumbled on this issue.  Perhaps this problem is exposed more often when
using an IBM JDK (which I'm using) since it may have different garbage
collection rules than the Sun JDK?  Thanks in advance for your help.

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to