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 14:36:23 GMT




Hi Vlada,

The more I think about it, the following scenario seems probable to me:

You wrote that you have put the torque.jar in the jre library path. So
maybe (I have no largeknowledge of class loaders) BasePeer tries to
instantiate the Map builder classes in the System class loader. In this
class loader, it cannot find the Map Builder classes.
This would result in the following:
- the static initializers of a Peer is called
- it calls BasePeer.getMapBuilder(String)
- This method cannot instantiate the Map Builder, but does not throw an
Exception (BUG, I have already added it to scarab)
- you end up with a message in your error log, but no other sign of the
error except no db maps present

Try to remove torque.jar from the jre path and (if you have a web
application) put it in WEB-INF/lib instead or (if you have a standalone
application) add it to the -classpath argument of your program start.

Please tell us if that worked.

      Thomas

Vlada Djurovic <vdjurovic@gmail.com> schrieb am 17.06.2005 15:24:46:

> This is what I got:
>
> In static initializer
> Torque initialized
> Map builder initialized
> BasePeer: tableName=patient
> BasePeer: dbName=cardiobip
> DBMap tables: {ID_TABLE=org.apache.torque.map.TableMap@ffd135}
> tableMap==null
> Exception occurred during event dispatching:
>
> Everything seems OK untill I call the tableMap. Looks like no
> tableMaps are added to dbMap, except for ID_TABLE.
> I use only one database, and that's the default.
> >
> >
> >
> > Hi,
> >
> > One quick shot: Do you use more than one database ? Database Maps are
per
> > database, and if the peer does not belong to the default db and you are
> > querying the default db, this problem appears.
> > You can check this by printing
> >
> > Torque.getDatabaseMap(PatientPeer.DATABASE_NAME).
> getTable(PatientPeer.TABLE_NAME)
> >
> > if this is not null, then the table is stored elswhere but not in the
> > default db.
> >
> >
> > But probably this is not the case. So we have to go deeper into it.
> > BasePatientPeer should have a static initializer similar to that:
> >
> >     static
> >     {
> >           NSUNIQUEID = "benutzer.NSUNIQUEID";
> >           NAME = "benutzer.NAME";
> >           VORNAME = "benutzer.VORNAME";
> >           if (Torque.isInit())
> >         {
> >             try
> >             {
> >                 getMapBuilder(BenutzerMapBuilder.CLASS_NAME);
> >             }
> >             catch (Exception e)
> >             {
> >                 log.error("Could not initialize Peer", e);
> >             }
> >         }
> >         else
> >         {
> >             Torque.registerMapBuilder(BenutzerMapBuilder.CLASS_NAME);
> >         }
> >     }
> >
> > Please put in the following debug messages to isolate the problem
further:
> >
> > static
> > {
> >     NSUNIQUEID = "benutzer.NSUNIQUEID";
> >     NAME = "benutzer.NAME";
> >     VORNAME = "benutzer.VORNAME";
> >     if (Torque.isInit())
> >     {
> >         System.out.println("Torque is initialized");
> >         try
> >         {
> >             getMapBuilder(BenutzerMapBuilder.CLASS_NAME);
> >             System.out.println("Map builder initialized");
> >         }
> >         catch (Exception e)
> >         {
> >             log.error("Could not initialize Peer", e);
> >             System.out.println("Could not initialize Peer" +
e.getMessage);
> >         }
> >     }
> >     else
> >     {
> >         System.out.println("Torque is NOT initialized");
> >         Torque.registerMapBuilder(BenutzerMapBuilder.CLASS_NAME);
> >     }
> > }
> >
> > and send the output
> >
> >     Thomas
> >
> > > OK, here's what I have so far:
> > > -I recompiled torque-3.1.1, and added this to
> > > BasePeer.doInsert(Criteria,Connection):
> > >
> > > DatabaseMap dbMap = Torque.getDatabaseMap(criteria.getDbName());
> > >         System.out.println("BasePeer: dbName="+criteria.getDbName());
> > >         dbMap.printTables(); //added this in DatabaseMap to print
tables
> > >         TableMap tableMap = dbMap.getTable(tableName);
> > >         if(tableMap==null)
> > >             System.out.println("tableMap==null");
> > >
> > > And after running the code, this is the output:
> > >
> > > In statis initializer
> > > Peer initialized
> > > BasePeer: tableName=patient
> > > BasePeer: dbName=cardiobip
> > > DBMap tables: {ID_TABLE=org.apache.torque.map.TableMap@49cf9f}
> > > tableMap==null
> > > Exception occurred during event dispatching:
> > > java.lang.NullPointerException
> > >         at
org.apache.torque.util.BasePeer.doInsert(BasePeer.java:666)
> > >         at
org.apache.torque.util.BasePeer.doInsert(BasePeer.java:603)
> > >         at com.euroicc.cardiobip.om.BasePatientPeer.
> > > doInsert(BasePatientPeer.ja
> > > a:228)
> > >         at com.euroicc.cardiobip.om.BasePatientPeer.
> > > doInsert(BasePatientPeer.ja
> > > a:201)
> > >         at com.euroicc.cardiobip.gui.NewPatientDialog.
> > > OKButtonActionPerformed(N
> > >
> > > So, I guess DBMap contains only one table, ID_TABLE and table
> > > 'patient' can not be found.
> > >
> > > But I have no clue what could be causing this. I suppose you are
right
> > > about it being a configuration issue, but what?
> > >
> > > @Raphael:
> > > I tried using object instead of criteria, but it's the same
> > >
> > > ---------------------------------------------------------------------
> > > 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