db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <fisc...@seitenbau.net>
Subject Re: hsqldb and NullPointerException
Date Fri, 17 Jun 2005 09:54:26 GMT





Hi Vlada,

look at
http://issues.apache.org/scarab/issues/id/TRQS228
to read about the problem in detail.

In a nutshell, for each table in a query, the corresponding Peer class has
to be loaded before the table can be used in a query. Loading the class
executes its static initializer and registers the Map Builder for the
table.
Since Torque 3.1.1, this is done if a coulumn name constant (like
PatientPeer.FIRSTNAME) in the Peer is accessed.
In earlier versions of Torque, this is done e.g. if you access a method of
the Peer (like PatientPeer.doInsert()).
So in your case, because you are accessing a method of the Peer for the
query, this should be ok for any versions of Torque.

I would guess that you have some unusual setup which breaks this mechanism.
(e.g., some weeks ago, someone had the same problem because he was using
Joins and RMI). To shed light on this, can you put a debug message in the
static initializer of BasePatientPeer to see when it is called ?

Please keep us informed about your findings

     Thomas


Vlada Djurovic <vdjurovic@gmail.com> schrieb am 17.06.2005 11:25:42:

> > Hi,
> >
> > can you append a stack trace and (if it is not inside Torque) the
relevant
> > part of code ?
> > It sounds a bit like a configuration issue. The classpath is
improbable, I
> > have never seen a NullPointerException thrown because of a classpath
issue
> >
> >             Thomas
> >
> Here's a part of stack trace:
> --------------------------------------------------
> Exception occurred during event dispatching:
> java.lang.NullPointerException
>         at org.apache.torque.util.BasePeer.doInsert(BasePeer.java:661)
>         at org.apache.torque.util.BasePeer.doInsert(BasePeer.java:603)
>         at com.euroicc.cardiobip.om.BasePatientPeer.
> doInsert(BasePatientPeer.jav
> a:223)
>         at com.euroicc.cardiobip.om.BasePatientPeer.
> doInsert(BasePatientPeer.jav
> a:196)
>         at com.euroicc.cardiobip.gui.NewPatientDialog.
> OKButtonActionPerformed(Ne
> wPatientDialog.java:413)
>
-----------------------------------------------------------------------------------

> And the code:
>
> ++++++++++++++++++++++++++++++++
>  Criteria crit=new Criteria();
>             crit.setDbName(Torque.getDefaultDB());
>             System.out.println("Database="+crit.getDbName());//for
debugging
>             crit.add(PatientPeer.FIRSTNAME,firstNameField.getText());
>             crit.add(PatientPeer.LASTNAME,lastNameField.getText());
>             crit.add(PatientPeer.HEIGHT,(new
> Integer(heightField.getText())).intValue());
>             crit.add(PatientPeer.WEIGHT,(new
> Integer(weightField.getText())).intValue());
>             crit.add(PatientPeer.CHEST,(new
> Integer(chestField.getText())).intValue());
>             crit.add(PatientPeer.BIRTHDATE,dateOfBirth);
>
>             ObjectKey ok=PatientPeer.doInsert(crit); ///HERE IS THE
EXCEPTION
> ++++++++++++++++++++++++++++++++++++++++++++++
>
> I did some lookin in Torque BasePeer class source, and it seems that
> it can't find appropriate table:
>
>         DatabaseMap dbMap = Torque.getDatabaseMap(criteria.getDbName());
>         TableMap tableMap = dbMap.getTable(tableName);  //THIS SEEMS
> TO RETURN null
>         Object keyInfo = tableMap.getPrimaryKeyMethodInfo();//EXCEPTION
NPE
>
> I hope you can shed some light on this. Thanks
>
>
> >
> > Vlada Djurovic <vdjurovic@gmail.com> schrieb am 17.06.2005 09:11:09:
> >
> > > > Hi,
> > > >
> > > > The usual way to cope with a null pointer exception is
> > > > 1) compile the sources with the debug option
> > > > 2) look at the stack trace to find out exactly where the exception
> > occurs
> > > > 3) look at the indicated line in the source code to see which
object is
> > > > null
> > > > 4) check (in the source code or elsewhere) why the object is null
> > > >
> > > > Did you already do that ?
> > > >
> > > >     Thomas
> > >
> > > Yes, I did that, and everything else I could think of, but couldn't
> > > find anything wrong. As I said, it works perfectly inside the IDE,
but
> > > not outside.
> > > When I run the app standalone, I can connect to database, do simple
> > > querries, but if I try to do INSERT, UPDATE,DELETE or join, I get the
> > > NPE.
> > > First I thought it's a classpath issue, but I guess, if I can connect
> > > to database and do some things, than the classpath and configuration
> > > are OK, right? I use the same libs in the IDE and outside it, so it
> > > should be OK too.
> > > This is really frustrating:-(
> > >
> > > Thanks for a tip anyway.
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > > For additional commands, e-mail: torque-user-help@db.apache.org
> > >
> >
> >
> > ------------------------------------- --------------------------------
> > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: torque-user-help@db.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message