You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Vlada Djurovic <vd...@gmail.com> on 2005/06/16 16:03:52 UTC

hsqldb and NullPointerException

Hi.
I'm not sure if this is the right place for this question, but I ran
out of optoions.
This is my problem: I'm using NetBeans IDE with HSQLDB and Torque for
development.  I managed to get everything working from inside the IDE,
but if try to run the app on it own, I get that damn
NullPointerException, and I can;t figure out what's causing them.
First I thought it's a classpath issue, but I got all the jars in
jre/lib/ext, Torque.properties file is in the right place and
everything looks OK.
Seems like this exception happens when I use doInsert() or Criteria
with addJoin() or addAscendingOrederByColumn().
I looked all the messages mentioning simmilar probelm, tried every
answer, but no luck.

If somebody could give me a hint what could be wrong, I would be most
gratefull...
Thanks in advance.

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


Re: hsqldb and NullPointerException

Posted by Vlada Djurovic <vd...@gmail.com>.
On 6/17/05, Raphael Mankin <ra...@mankin.org.uk> wrote:
> I had strange problems (weird Oracle errors rather than NPE) when I
> accidentally did an INSERT on something that already had a key. Are you maybe
> cloning or modifying an existing object and then trying to save it as new? That
> can cause weirdnesses.
> 
> 
orque-user-help@db.apache.org
> 
Well, I'm not sure. I'm using HSQLDB embedded, and I set
defaultIdMethod="native" in project-schema.xml and
autoincrement="true". I suppose HSQLDB would automaticaly create new
primary key for each new entry.
Anyway, in my code, I specificaly do INSERT of a new object. Maybe I'l
try ti use IDbroker instead of native? I'll try that and get back to
you.

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


Re: hsqldb and NullPointerException

Posted by Vlada Djurovic <vd...@gmail.com>.
> 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
> 

SUCCESS!!!!!!!!!!!!!!!!!!FINALY! That was it.
I can't believe we did it. Thanks a lot, Thomas, I oaw you one.
I knew this would be something stupid, but I would've never thought of this.
Thanks again, man, I hope I'll be able to return the favor some day ;-).

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


Re: hsqldb and NullPointerException

Posted by Thomas Fischer <fi...@seitenbau.net>.



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 <vd...@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


Re: hsqldb and NullPointerException

Posted by Thomas Fischer <fi...@seitenbau.net>.



Ok, so far we have
- Torque is initialized when PatientBasePeer is loaded
- No exception is thrown when BasePeer.getMapBuilder(String) is called
(this does not mean anything, see below)

Fisr path of action is looking into the Map builder. It is located in the
map subpackage of the package where you generate the OM classes in and is
called
PatientMapBuilder.

It should have a doBuild() method, which should get called by the line

getMapBuilder(PatientMapBuilder.CLASS_NAME);

in the static initializer of PatientPeer.

The dobuild() method should look similar to this:
    public void doBuild() throws TorqueException
    {
        dbMap = Torque.getDatabaseMap("nameOfYourDefaultDb");

        dbMap.addTable("benutzer");
        TableMap tMap = dbMap.getTable("benutzer");

        tMap.setPrimaryKeyMethod("none");


              tMap.addPrimaryKey("benutzer.NSUNIQUEID", new String());
                    tMap.addColumn("benutzer.NAME", new String());
                    tMap.addColumn("benutzer.VORNAME", new String());
        }

Can you please put a debug message into this method to see if it is called
?
If yes, can you replace the line

dbMap = Torque.getDatabaseMap("nameOfYourDefaultDb");

by

Torque.getDatabaseMap(Torque.getDefaultDb());

and see if it changes anything ?

If this does not change anything, can you print the contents of the
database map at the end of the method ? Then, the table should be there.
Perhaps it disappears again somewhere in between....


Second path of action(if doBuild() in the Map builders is NOT getting
called): I have noticed that in BasePeer.getMapBuilder(String), all
exceptions are caught and NOT rethrown; only a log message is written. Do
you have a Torque logfile ? If yes, does it contain an error message like

BasePeer.MapBuilder failed trying to instantiate.....

If you have no log file, can you put a system.out.println in the catch
block in BasePeer.getMapBuilder(String) and see if it runs into this.

    Thomas


Vlada Djurovic <vd...@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


Re: hsqldb and NullPointerException

Posted by Vlada Djurovic <vd...@gmail.com>.
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


Re: hsqldb and NullPointerException

Posted by Thomas Fischer <fi...@seitenbau.net>.



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


Re: hsqldb and NullPointerException

Posted by Vlada Djurovic <vd...@gmail.com>.
> 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
> 
> 
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


Re: hsqldb and NullPointerException

Posted by Thomas Fischer <fi...@seitenbau.net>.




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 <vd...@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 <vd...@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


Re: hsqldb and NullPointerException

Posted by Vlada Djurovic <vd...@gmail.com>.
> 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 <vd...@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


Re: hsqldb and NullPointerException

Posted by Raphael Mankin <ra...@mankin.org.uk>.
I had strange problems (weird Oracle errors rather than NPE) when I
accidentally did an INSERT on something that already had a key. Are you maybe
cloning or modifying an existing object and then trying to save it as new? That
can cause weirdnesses.


On 17-Jun-2005 Vlada Djurovic wrote:
>> 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

-- 
                               Lead us not into temptation; we
                               can find our own way.


Raphael Mankin
----------------------------------

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


Re: hsqldb and NullPointerException

Posted by Thomas Fischer <fi...@seitenbau.net>.



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


Vlada Djurovic <vd...@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


Re: hsqldb and NullPointerException

Posted by Vlada Djurovic <vd...@gmail.com>.
> 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


RE: hsqldb and NullPointerException

Posted by Thomas Fischer <fi...@seitenbau.net>.



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

Vlada Djurovic <vd...@gmail.com> schrieb am 16.06.2005 16:03:52:

> Hi.
> I'm not sure if this is the right place for this question, but I ran
> out of optoions.
> This is my problem: I'm using NetBeans IDE with HSQLDB and Torque for
> development.  I managed to get everything working from inside the IDE,
> but if try to run the app on it own, I get that damn
> NullPointerException, and I can;t figure out what's causing them.
> First I thought it's a classpath issue, but I got all the jars in
> jre/lib/ext, Torque.properties file is in the right place and
> everything looks OK.
> Seems like this exception happens when I use doInsert() or Criteria
> with addJoin() or addAscendingOrederByColumn().
> I looked all the messages mentioning simmilar probelm, tried every
> answer, but no luck.
>
> If somebody could give me a hint what could be wrong, I would be most
> gratefull...
> Thanks in advance.
>
> ---------------------------------------------------------------------
> 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