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 "Owen B. Mehegan" <om...@hi5.com> on 2008/02/07 02:50:45 UTC

No DataSourceFactory configured

Hi, I've seen this question asked many times in the mailing list 
archives, but so far I can't figure out a solution to the problem in my 
case. I have a unit test that is using Easymock to create mock database 
objects to test against. When I run the test, it always fails with this 
error:

java.lang.NullPointerException: There was no DataSourceFactory 
configured for the connection recoverable

But my Torque.properties _does_ include a datasource called 'recoverable:'

torque.dsfactory.recoverable.factory=com.friend.db.RecoverableDataSourceFactory
torque.dsfactory.recoverable.pool.maxActive=1
torque.dsfactory.recoverable.pool.maxIdle=1
torque.dsfactory.recoverable.pool.maxWait=1000
torque.dsfactory.recoverable.pool.testOnBorrow=false
torque.dsfactory.recoverable.pool.validationQuery=SELECT 1
torque.dsfactory.recoverable.connection.driver=com.mockrunner.mock.jdbc.MockDriver
torque.dsfactory.recoverable.connection.url = java://foo
torque.dsfactory.recoverable.connection.user = user
torque.dsfactory.recoverable.connection.password = foo

This entry is similar to others in the torque.properties, so I don't 
think the syntax is incorrect. What else could I be doing wrong?

-- 
Owen B. Mehegan
Database Framework QA Guy
"He is a dangerous mixture of sophistication and recklessness which
makes one anxious about his influence on other boys."

omehegan@hi5.com
YIM: omehegan
AIM: ottomaticjack
GTalk: omehegan@gmail.com

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


Re: No DataSourceFactory configured

Posted by Guy Galil <gu...@guardium.com>.
Do you call Torque.init() in your code before any attempt to use the
connection?

On Wed, 2008-02-06 at 17:50 -0800, Owen B. Mehegan wrote:
> Hi, I've seen this question asked many times in the mailing list 
> archives, but so far I can't figure out a solution to the problem in my 
> case. I have a unit test that is using Easymock to create mock database 
> objects to test against. When I run the test, it always fails with this 
> error:
> 
> java.lang.NullPointerException: There was no DataSourceFactory 
> configured for the connection recoverable
> 
> But my Torque.properties _does_ include a datasource called 'recoverable:'
> 
> torque.dsfactory.recoverable.factory=com.friend.db.RecoverableDataSourceFactory
> torque.dsfactory.recoverable.pool.maxActive=1
> torque.dsfactory.recoverable.pool.maxIdle=1
> torque.dsfactory.recoverable.pool.maxWait=1000
> torque.dsfactory.recoverable.pool.testOnBorrow=false
> torque.dsfactory.recoverable.pool.validationQuery=SELECT 1
> torque.dsfactory.recoverable.connection.driver=com.mockrunner.mock.jdbc.MockDriver
> torque.dsfactory.recoverable.connection.url = java://foo
> torque.dsfactory.recoverable.connection.user = user
> torque.dsfactory.recoverable.connection.password = foo
> 
> This entry is similar to others in the torque.properties, so I don't 
> think the syntax is incorrect. What else could I be doing wrong?
> 


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


Re: No DataSourceFactory configured

Posted by "Owen B. Mehegan" <om...@hi5.com>.
I got resolution of this issue - there was a bug elsewhere in the 
classes we're using to initialize Torque; they were calling the wrong 
torque.properties file. It was impossible to determine from my unit 
test, but when I went higher up the chain we figured it out.

Owen B. Mehegan wrote:
> Hi, I've seen this question asked many times in the mailing list 
> archives, but so far I can't figure out a solution to the problem in my 
> case. I have a unit test that is using Easymock to create mock database 
> objects to test against. When I run the test, it always fails with this 
> error:
> 
> java.lang.NullPointerException: There was no DataSourceFactory 
> configured for the connection recoverable
> 
> But my Torque.properties _does_ include a datasource called 'recoverable:'
> 
> torque.dsfactory.recoverable.factory=com.friend.db.RecoverableDataSourceFactory 
> 
> torque.dsfactory.recoverable.pool.maxActive=1
> torque.dsfactory.recoverable.pool.maxIdle=1
> torque.dsfactory.recoverable.pool.maxWait=1000
> torque.dsfactory.recoverable.pool.testOnBorrow=false
> torque.dsfactory.recoverable.pool.validationQuery=SELECT 1
> torque.dsfactory.recoverable.connection.driver=com.mockrunner.mock.jdbc.MockDriver 
> 
> torque.dsfactory.recoverable.connection.url = java://foo
> torque.dsfactory.recoverable.connection.user = user
> torque.dsfactory.recoverable.connection.password = foo
> 
> This entry is similar to others in the torque.properties, so I don't 
> think the syntax is incorrect. What else could I be doing wrong?
> 

-- 
Owen B. Mehegan
Database Framework QA Guy
"He is a dangerous mixture of sophistication and recklessness which
makes one anxious about his influence on other boys."

omehegan@hi5.com
YIM: omehegan
AIM: ottomaticjack
GTalk: omehegan@gmail.com

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


Re: No DataSourceFactory configured

Posted by "Owen B. Mehegan" <om...@hi5.com>.
Oh, I see what you were getting at, sorry! I obfuscated the actual value 
of 'url' in this email, since I considered it to be sensitive data :)

Alvaro Coronel wrote:
> torque.dsfactory.recoverable.connection.url looks yucky.
> 
> 
> "Owen B. Mehegan" <om...@hi5.com> wrote: Hi, I've seen this question asked many times in the mailing list 
> archives, but so far I can't figure out a solution to the problem in my 
> case. I have a unit test that is using Easymock to create mock database 
> objects to test against. When I run the test, it always fails with this 
> error:
> 
> java.lang.NullPointerException: There was no DataSourceFactory 
> configured for the connection recoverable
> 
> But my Torque.properties _does_ include a datasource called 'recoverable:'
> 
> torque.dsfactory.recoverable.factory=com.friend.db.RecoverableDataSourceFactory
> torque.dsfactory.recoverable.pool.maxActive=1
> torque.dsfactory.recoverable.pool.maxIdle=1
> torque.dsfactory.recoverable.pool.maxWait=1000
> torque.dsfactory.recoverable.pool.testOnBorrow=false
> torque.dsfactory.recoverable.pool.validationQuery=SELECT 1
> torque.dsfactory.recoverable.connection.driver=com.mockrunner.mock.jdbc.MockDriver
> torque.dsfactory.recoverable.connection.url = java://foo
> torque.dsfactory.recoverable.connection.user = user
> torque.dsfactory.recoverable.connection.password = foo
> 
> This entry is similar to others in the torque.properties, so I don't 
> think the syntax is incorrect. What else could I be doing wrong?
> 

-- 
Owen B. Mehegan
Database Framework QA Guy
"He is a dangerous mixture of sophistication and recklessness which
makes one anxious about his influence on other boys."

omehegan@hi5.com
YIM: omehegan
AIM: ottomaticjack
GTalk: omehegan@gmail.com

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


Re: No DataSourceFactory configured

Posted by "Owen B. Mehegan" <om...@hi5.com>.
Well, RecoverableDataSourceFactory is apparently just one of the 
standard Torque drivers, which we just happen to store in a logical 
location in our source tree. The comment at the top of that source file 
says:

/**
  * A factory that looks up the DataSource using the JDBC2 pool methods.
  *
  * @author <a href="mailto:jmcnally@apache.org">John McNally</a>
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
  * @version $Id: SharedPoolDataSourceFactory.java,v 1.1 2003/08/19 
19:09:12 mpoeschl Exp $
  */

So I don't think that's too weird...

Alvaro Coronel wrote:
> torque.dsfactory.recoverable.connection.url looks yucky.
> 
> 
> "Owen B. Mehegan" <om...@hi5.com> wrote: Hi, I've seen this question asked many times in the mailing list 
> archives, but so far I can't figure out a solution to the problem in my 
> case. I have a unit test that is using Easymock to create mock database 
> objects to test against. When I run the test, it always fails with this 
> error:
> 
> java.lang.NullPointerException: There was no DataSourceFactory 
> configured for the connection recoverable
> 
> But my Torque.properties _does_ include a datasource called 'recoverable:'
> 
> torque.dsfactory.recoverable.factory=com.friend.db.RecoverableDataSourceFactory
> torque.dsfactory.recoverable.pool.maxActive=1
> torque.dsfactory.recoverable.pool.maxIdle=1
> torque.dsfactory.recoverable.pool.maxWait=1000
> torque.dsfactory.recoverable.pool.testOnBorrow=false
> torque.dsfactory.recoverable.pool.validationQuery=SELECT 1
> torque.dsfactory.recoverable.connection.driver=com.mockrunner.mock.jdbc.MockDriver
> torque.dsfactory.recoverable.connection.url = java://foo
> torque.dsfactory.recoverable.connection.user = user
> torque.dsfactory.recoverable.connection.password = foo
> 
> This entry is similar to others in the torque.properties, so I don't 
> think the syntax is incorrect. What else could I be doing wrong?
> 

-- 
Owen B. Mehegan
Database Framework QA Guy
"He is a dangerous mixture of sophistication and recklessness which
makes one anxious about his influence on other boys."

omehegan@hi5.com
YIM: omehegan
AIM: ottomaticjack
GTalk: omehegan@gmail.com

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


Re: No DataSourceFactory configured

Posted by Alvaro Coronel <al...@yahoo.com>.
torque.dsfactory.recoverable.connection.url looks yucky.


"Owen B. Mehegan" <om...@hi5.com> wrote: Hi, I've seen this question asked many times in the mailing list 
archives, but so far I can't figure out a solution to the problem in my 
case. I have a unit test that is using Easymock to create mock database 
objects to test against. When I run the test, it always fails with this 
error:

java.lang.NullPointerException: There was no DataSourceFactory 
configured for the connection recoverable

But my Torque.properties _does_ include a datasource called 'recoverable:'

torque.dsfactory.recoverable.factory=com.friend.db.RecoverableDataSourceFactory
torque.dsfactory.recoverable.pool.maxActive=1
torque.dsfactory.recoverable.pool.maxIdle=1
torque.dsfactory.recoverable.pool.maxWait=1000
torque.dsfactory.recoverable.pool.testOnBorrow=false
torque.dsfactory.recoverable.pool.validationQuery=SELECT 1
torque.dsfactory.recoverable.connection.driver=com.mockrunner.mock.jdbc.MockDriver
torque.dsfactory.recoverable.connection.url = java://foo
torque.dsfactory.recoverable.connection.user = user
torque.dsfactory.recoverable.connection.password = foo

This entry is similar to others in the torque.properties, so I don't 
think the syntax is incorrect. What else could I be doing wrong?

-- 
Owen B. Mehegan
Database Framework QA Guy
"He is a dangerous mixture of sophistication and recklessness which
makes one anxious about his influence on other boys."

omehegan@hi5.com
YIM: omehegan
AIM: ottomaticjack
GTalk: omehegan@gmail.com

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



       
---------------------------------
Never miss a thing.   Make Yahoo your homepage.

Re: No DataSourceFactory configured

Posted by "Owen B. Mehegan" <om...@hi5.com>.
Yeah, I'm experimenting with your suggestions now. My torque.properties 
includes three other entries. These three are identical except in name:

torque.dsfactory.friend.factory=com.friend.db.MockDataSourceFactory
torque.dsfactory.friend.pool.maxActive=22
torque.dsfactory.friend.pool.maxIdle=22
torque.dsfactory.friend.pool.testOnBorrow=true
torque.dsfactory.friend.pool.validationQuery=SELECT 1
torque.dsfactory.friend.connection.driver = org.postgresql.Driver
torque.dsfactory.friend.connection.url = java://stuff
torque.dsfactory.friend.connection.user = stuff
torque.dsfactory.friend.connection.password =

So the difference between these and my 'recoverable' data source is, 
'recoverable' uses these two config options:

torque.dsfactory.recoverable.factory=com.friend.db.RecoverableDataSourceFactory
torque.dsfactory.recoverable.connection.driver=com.mockrunner.mock.jdbc.MockDriver

I've tried using all three of these in my test. One of them fails with 
the same "There was no DataSourceFactory configured" error as 
'recoverable.' The other two fail with: 
java.util.NoSuchElementException: Could not create a validated object

I've inherited this code from someone else, so it may be that I need to 
find out more about how we're using it. I was just hoping the issue was 
something simple related to Torque itself.

Frank Nguyen wrote:
> Were you able to connect to any other database than "recoverable" database? what driver did you use ? were you able to connect to recoverable database itself using JDBC test with the same username and password? Lastly, try using different different dsfactory to see if it works for you. Here is my sample setup with my youcaddy database. 
> 
> ## Using commons-dbcp
> torque.dsfactory.youcaddy.factory=org.apache.torque.dsfactory.SharedPoolDataSourceFactory
> #torque.dsfactory.youcaddy.factory=org.apache.torque.dsfactory.PerUserPoolDataSourceFactor
> y
> torque.dsfactory.youcaddy.pool.defaultMaxActive=10
> torque.dsfactory.youcaddy.pool.testOnBorrow=true
> torque.dsfactory.youcaddy.pool.validationQuery=SELECT 1
> torque.dsfactory.youcaddy.connection.driver = org.gjt.mm.mysql.Driver
> torque.dsfactory.youcaddy.connection.url = jdbc:mysql://localhost/youcaddy
> torque.dsfactory.youcaddy.connection.user = bla
> torque.dsfactory.youcaddy.connection.password = bla
> 
> Good luck !
> 
> "Owen B. Mehegan" <om...@hi5.com> wrote: Hi, I've seen this question asked many times in the mailing list 
> archives, but so far I can't figure out a solution to the problem in my 
> case. I have a unit test that is using Easymock to create mock database 
> objects to test against. When I run the test, it always fails with this 
> error:
> 
> java.lang.NullPointerException: There was no DataSourceFactory 
> configured for the connection recoverable
> 
> But my Torque.properties _does_ include a datasource called 'recoverable:'
> 
> torque.dsfactory.recoverable.factory=com.friend.db.RecoverableDataSourceFactory
> torque.dsfactory.recoverable.pool.maxActive=1
> torque.dsfactory.recoverable.pool.maxIdle=1
> torque.dsfactory.recoverable.pool.maxWait=1000
> torque.dsfactory.recoverable.pool.testOnBorrow=false
> torque.dsfactory.recoverable.pool.validationQuery=SELECT 1
> torque.dsfactory.recoverable.connection.driver=com.mockrunner.mock.jdbc.MockDriver
> torque.dsfactory.recoverable.connection.url = java://foo
> torque.dsfactory.recoverable.connection.user = user
> torque.dsfactory.recoverable.connection.password = foo
> 
> This entry is similar to others in the torque.properties, so I don't 
> think the syntax is incorrect. What else could I be doing wrong?
> 

-- 
Owen B. Mehegan
Database Framework QA Guy
"He is a dangerous mixture of sophistication and recklessness which
makes one anxious about his influence on other boys."

omehegan@hi5.com
YIM: omehegan
AIM: ottomaticjack
GTalk: omehegan@gmail.com

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


Re: No DataSourceFactory configured

Posted by Frank Nguyen <fr...@sbcglobal.net>.
Were you able to connect to any other database than "recoverable" database? what driver did you use ? were you able to connect to recoverable database itself using JDBC test with the same username and password? Lastly, try using different different dsfactory to see if it works for you. Here is my sample setup with my youcaddy database. 

## Using commons-dbcp
torque.dsfactory.youcaddy.factory=org.apache.torque.dsfactory.SharedPoolDataSourceFactory
#torque.dsfactory.youcaddy.factory=org.apache.torque.dsfactory.PerUserPoolDataSourceFactor
y
torque.dsfactory.youcaddy.pool.defaultMaxActive=10
torque.dsfactory.youcaddy.pool.testOnBorrow=true
torque.dsfactory.youcaddy.pool.validationQuery=SELECT 1
torque.dsfactory.youcaddy.connection.driver = org.gjt.mm.mysql.Driver
torque.dsfactory.youcaddy.connection.url = jdbc:mysql://localhost/youcaddy
torque.dsfactory.youcaddy.connection.user = bla
torque.dsfactory.youcaddy.connection.password = bla

Good luck !

"Owen B. Mehegan" <om...@hi5.com> wrote: Hi, I've seen this question asked many times in the mailing list 
archives, but so far I can't figure out a solution to the problem in my 
case. I have a unit test that is using Easymock to create mock database 
objects to test against. When I run the test, it always fails with this 
error:

java.lang.NullPointerException: There was no DataSourceFactory 
configured for the connection recoverable

But my Torque.properties _does_ include a datasource called 'recoverable:'

torque.dsfactory.recoverable.factory=com.friend.db.RecoverableDataSourceFactory
torque.dsfactory.recoverable.pool.maxActive=1
torque.dsfactory.recoverable.pool.maxIdle=1
torque.dsfactory.recoverable.pool.maxWait=1000
torque.dsfactory.recoverable.pool.testOnBorrow=false
torque.dsfactory.recoverable.pool.validationQuery=SELECT 1
torque.dsfactory.recoverable.connection.driver=com.mockrunner.mock.jdbc.MockDriver
torque.dsfactory.recoverable.connection.url = java://foo
torque.dsfactory.recoverable.connection.user = user
torque.dsfactory.recoverable.connection.password = foo

This entry is similar to others in the torque.properties, so I don't 
think the syntax is incorrect. What else could I be doing wrong?

-- 
Owen B. Mehegan
Database Framework QA Guy
"He is a dangerous mixture of sophistication and recklessness which
makes one anxious about his influence on other boys."

omehegan@hi5.com
YIM: omehegan
AIM: ottomaticjack
GTalk: omehegan@gmail.com

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