db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Moiseyev <ser...@peoplelogic.com.au>
Subject Re: java.lang.NullPointerException: There was no DataSourceFactory configured for the connection bookstore
Date Tue, 28 Oct 2003 02:56:45 GMT
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:39
>)
> at
>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
>.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(RemoteTestRu
>nner.java:392)
> at
>org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.
>java:276)
> at
>org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner
>.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.TorqueDataSou
>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
>>
>>
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>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