db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Chelimsky" <da...@chelimsky.org>
Subject Re: java.lang.NullPointerException: There was no DataSourceFactory configured for the connection bookstore
Date Tue, 28 Oct 2003 02:51:25 GMT
Thanks Sergey, but that's not the issue apparently. Here's the results of
querying the id_table directly:

mysql> select * from id_table;
+-------------+------------+---------+----------+
| ID_TABLE_ID | TABLE_NAME | NEXT_ID | QUANTITY |
+-------------+------------+---------+----------+
|         101 | account    |    1000 |       10 |
+-------------+------------+---------+----------+
1 row in set (0.00 sec)

I tried rebuilding just for kicks, but same result - the query is as above
and the error is as below. I'll include my schema files - maybe there's
something obvious here that I'm just not seeing. Thanks for checking it out.

<!-- 
==================================================================== -->
<!-- id-table-schema.xml        -->
<!-- 
==================================================================== -->
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE database SYSTEM
"http://db.apache.org/torque/dtd/database_3_1.dtd">

<!-- 
==================================================================== -->
<!--                                                                      --
>
<!-- I D  B R O K E R  S C H E M
  -->
<!--                                                                      --
>
<!-- 
==================================================================== -->
<!-- This is the XML schema use by Torque to generate the SQL
    -->
<!-- ID_TABLE table used by the id broker mechanism in
        -->
<!-- 
==================================================================== -->
<!-- @author: <a href="mailto:jvanzyl@apache.org">Jason van
>       -->
<!-- @version $Id: id-table-schema.xml,v 1.2 2003/07/24 12:40:41 mpoeschl
Exp $ -->
<!-- 
==================================================================== -->

<database name="tools">
  <table name="ID_TABLE" idMethod="idbroker">
    <column name="ID_TABLE_ID" required="true" primaryKey="true"
type="INTEGER"/>
    <column name="TABLE_NAME" required="true" size="255" type="VARCHAR"/>
    <column name="NEXT_ID" type="INTEGER"/>
    <column name="QUANTITY" type="INTEGER"/>

    <unique>
      <unique-column name="TABLE_NAME"/>
    </unique>

  </table>
</database>


<!-- 
==================================================================== -->
<!-- tools-schema.xml         -->
<!-- 
==================================================================== -->
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE database SYSTEM
 "http://db.apache.org/torque/dtd/database_3_1.dtd">

<database name="tools" defaultIdMethod="idBroker">
 <table name="account" description="Account Table">
  <column
   name="account_id"
   required="true"
   primaryKey="true"
   type="INTEGER"
   description="User Id"
  />
  <column
   name="name"
   required="true"
   type="VARCHAR"
   size="255"
   description="Account Name"
  />
 </table>
</database>


----- Original Message ----- 
From: "Sergey Moiseyev" <sergey@peoplelogic.com.au>
To: "Apache Torque Users List" <torque-user@db.apache.org>
Sent: Monday, October 27, 2003 8:56 PM
Subject: Re: java.lang.NullPointerException: There was no DataSourceFactory
configured for the connection bookstore


> Hi David
>
> It looks like you are using IdGenerator, am I right?
> So you have defautlIdMethod="idbroker" in your schema file?
> In this case you have to make sure that you have ID table in your
> database and that this table is populated with data.
> Here what you should do to archive that:
> 1) make sure id-table-schema.xml is in your schema directory
> 2) rebuild your project
>     ant -f bulid-torque.xml
> 3) create init sql for id_table:
>     ant -f build-torque.xml id-table-init-sql
> This will create a script to populate the id table.
> 4) populate the database
>     ant -f build-torque.xml insert-sql
>
> The NullPointException in my previous post was because I was doing
> something silly!
> I played around with changing  defaultIdMethod and running some test but
> I didn't rebuild my project properly.
>
>
> Hope that helps,
> Sergey
>
> David Chelimsky wrote:
>
> >Thanks Sergey. I've gotten past the NullPointerException. Now I'm getting
> >"org.apache.torque.TorqueException: IdGenerator for table 'account' is
> >null". I see you posted this problem yourself but I don't see if there
was
> >ever a resolution. Was there?
> >
> >===================================================
> >org.apache.torque.TorqueException: IdGenerator for table 'account' is
null
> > at org.apache.torque.util.BasePeer.doInsert(BasePeer.java:708)
> > at
> >org.chelimsky.tools.om.BaseAccountPeer.doInsert(BaseAccountPeer.java:212)
> > at
> >org.chelimsky.tools.om.BaseAccountPeer.doInsert(BaseAccountPeer.java:556)
> > at org.chelimsky.tools.om.BaseAccount.save(BaseAccount.java:248)
> > at org.chelimsky.tools.om.BaseAccount.save(BaseAccount.java:212)
> > at org.chelimsky.tools.om.BaseAccount.save(BaseAccount.java:192)
> > at org.chelimsky.tools.om.AccountTest.testToString(AccountTest.java:49)
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > at
>
>sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:3
9
> >)
> > at
>
>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp
l
> >.java:25)
> > at java.lang.reflect.Method.invoke(Method.java:324)
> > at junit.framework.TestCase.runTest(TestCase.java:154)
> > at junit.framework.TestCase.runBare(TestCase.java:127)
> > at junit.framework.TestResult$1.protect(TestResult.java:106)
> > at junit.framework.TestResult.runProtected(TestResult.java:124)
> > at junit.framework.TestResult.run(TestResult.java:109)
> > at junit.framework.TestCase.run(TestCase.java:118)
> > at junit.framework.TestSuite.runTest(TestSuite.java:208)
> > at junit.framework.TestSuite.run(TestSuite.java:203)
> > at
>
>org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestR
u
> >nner.java:392)
> > at
>
>org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner
.
> >java:276)
> > at
>
>org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunne
r
> >.java:167)
> >===================================================
> >
> >
> >
> >----- Original Message ----- 
> >From: "Sergey Moiseyev" <sergey@peoplelogic.com.au>
> >To: "Apache Torque Users List" <torque-user@db.apache.org>
> >Sent: Sunday, October 26, 2003 8:53 PM
> >Subject: Re: java.lang.NullPointerException: There was no
DataSourceFactory
> >configured for the connection bookstore
> >
> >
> >
> >
> >>Hi David
> >>
> >>Try to add the following lines to your property file:
> >>
> >>
> >>
> >>
>
>torque.dsfactory.bookstore.factory=org.apache.torque.dsfactory.TorqueDataSo
u
> >rceFactory
> >
> >
> >>torque.dsfactory.bookstore.pool.defaultMaxConnections=10
> >>torque.dsfactory.bookstore.pool.maxExpiryTime=3600
> >>torque.dsfactory.bookstore.pool.connectionWaitTimeout=10
> >>torque.dsfactory.bookstore.connection.driver = org.gjt.mm.mysql.Driver
> >>torque.dsfactory.bookstore.connection.url =
> >>
> >>
> >jdbc:mysql://127.0.0.1/bookstore
> >
> >
> >>torque.dsfactory.bookstore.connection.user =
> >>torque.dsfactory.bookstore.connection.password =
> >>
> >>This is taken from the Torque.properties file which is located int the
> >>root directory of the torque-3.1  distribution.
> >>
> >>Cheers,
> >>
> >>Sergey
> >>
> >>David Chelimsky wrote:
> >>
> >>
> >>
> >>>Hi. I believe that I'm following the tutorial
> >>>
> >>>
> >(http://db.apache.org/torque/tutorial) to the letter, but when I get to
> >executing the Bookstore program (java com.kazmier.Bookstore), I get the
> >following message:
> >
> >
> >>>java.lang.NullPointerException: There was no DataSourceFactory
configured
> >>>
> >>>
> >for the connection bookstore
> >
> >
> >>>       at
> >>>
> >>>
> >org.apache.torque.TorqueInstance.getConnection(TorqueInstance.java:749)
> >
> >
> >>>       at org.apache.torque.Torque.getConnection(Torque.java:306)
> >>>       at
> >>>
> >>>
> >org.apache.torque.util.Transaction.beginOptional(Transaction.java:118)
> >
> >
> >>>       at
org.apache.torque.util.Transaction.begin(Transaction.java:100)
> >>>       at com.kazmier.om.BasePublisher.save(BasePublisher.java:490)
> >>>       at com.kazmier.om.BasePublisher.save(BasePublisher.java:471)
> >>>       at com.kazmier.Bookstore.main(Bookstore.java:26)
> >>>
> >>>Note that at this point, I can see that the object model and various
sql
> >>>
> >>>
> >files are correctly created AND I can see that the database and relevant
> >tables have been created. So I think that something is working at build
time
> >that is failing at run time.
> >
> >
> >>>Here's build.properties:
> >>>========================================================
> >>>torque.jar = torque-3.1.jar
> >>>torque.project = bookstore
> >>>torque.database = mysql
> >>>torque.targetPackage = com.kazmier.om
> >>>torque.database.createUrl = jdbc:mysql://127.0.0.1:3306/mysql
> >>>torque.database.buildUrl = jdbc:mysql://127.0.0.1:3306/bookstore
> >>>torque.database.url = jdbc:mysql://127.0.0.1:3306/bookstore
> >>>torque.database.driver = org.gjt.mm.mysql.Driver
> >>>torque.database.user =
> >>>torque.database.password =
> >>>torque.database.host = 127.0.0.1
> >>>========================================================
> >>>
> >>>And here's Torque.properties
> >>>========================================================
> >>>log4j.rootCategory = DEBUG, default
> >>>log4j.appender.default = org.apache.log4j.FileAppender
> >>>log4j.appender.default.file = ./torque.log
> >>>log4j.appender.default.layout = org.apache.log4j.SimpleLayout
> >>>
> >>>torque.database.default = bookstore
> >>>torque.database.bookstore.driver = org.gjt.mm.mysql.Driver
> >>>torque.database.bookstore.url = jdbc:mysql://127.0.0.1:3306/bookstore
> >>>torque.database.bookstore.username =
> >>>torque.database.bookstore.password =
> >>>========================================================


---------------------------------------------------------------------
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