John,
Sorry about that...
Torque is init'd like thus (from a load-on-startup=2 servlet):
try {
Class theClass = this.getClass();
ClassLoader theLoader = theClass.getClassLoader();
PropertiesConfiguration tconfig = new
PropertiesConfiguration();
tconfig.load(theLoader.getResourceAsStream("Torque.properties"));
org.apache.torque.Torque.init(tconfig);
}
catch (IOException ioe) {
logger.error("Could not find Torque config file", ioe);
}
catch (TorqueException te) {
logger.error("Could not init Torque", te);
}
The relevant parts from Torque.properties are as follows:
(note: that the jdbc2 and jndi methods I have tried but are still
commented out)
--------- START Torque.properties -----------
torque.applicationRoot = .
torque.database.default=XP
torque.database.XP.driver = org.gjt.mm.mysql.Driver
torque.database.XP.url = jdbc:mysql://127.0.0.1/XP
torque.database.XP.username = admin
torque.database.XP.password =
torque.database.default.adapter=mysql
torque.database.XP.adapter=mysql
## Using torque's old pool
#torque.dsfactory.default.factory=org.apache.torque.dsfactory.TorqueData
SourceFactory
#torque.dsfactory.default.pool.defaultMaxConnections=10
#torque.dsfactory.default.pool.maxExpiryTime=3600
#torque.dsfactory.default.pool.connectionWaitTimeout=10
#torque.dsfactory.default.connection.driver = org.gjt.mm.mysql.Driver
#torque.dsfactory.default.connection.url = jdbc:mysql://localhost/XP
#torque.dsfactory.default.connection.user = user
#torque.dsfactory.default.connection.password = password
torque.dsfactory.XP.factory=org.apache.torque.dsfactory.TorqueDataSource
Factory
torque.dsfactory.XP.pool.defaultMaxConnections=10
torque.dsfactory.XP.pool.maxExpiryTime=3600
torque.dsfactory.XP.pool.connectionWaitTimeout=10
torque.dsfactory.XP.connection.driver = org.gjt.mm.mysql.Driver
torque.dsfactory.XP.connection.url = jdbc:mysql://localhost/XP
torque.dsfactory.XP.connection.user = user
torque.dsfactory.XP.connection.password =
## Using Jdbc2Pool
#torque.dsfactory.default.factory=org.apache.torque.dsfactory.Jdbc2PoolD
ataSourceFactory
#torque.dsfactory.default.pool.defaultMaxActive=10
#torque.dsfactory.default.pool.testOnBorrow=true
#torque.dsfactory.default.pool.validationQuery=SELECT 1
#torque.dsfactory.default.connection.driver = org.gjt.mm.mysql.Driver
#torque.dsfactory.default.connection.url = jdbc:mysql://localhost/XP
#torque.dsfactory.default.connection.user = user
#torque.dsfactory.default.connection.password =
#torque.dsfactory.XP.factory=org.apache.torque.dsfactory.Jdbc2PoolDataSo
urceFactory
#torque.dsfactory.XP.pool.defaultMaxActive=10
#torque.dsfactory.XP.pool.testOnBorrow=true
#torque.dsfactory.XP.pool.validationQuery=SELECT 1
#torque.dsfactory.XP.connection.driver = org.gjt.mm.mysql.Driver
#torque.dsfactory.XP.connection.url = jdbc:mysql://localhost/XP
#torque.dsfactory.XP.connection.user = admin
#torque.dsfactory.XP.connection.password =
## Using jndi
#torque.dsfactory.default.factory=org.apache.torque.dsfactory.JndiDataSo
urceFactory
#torque.dsfactory.default.jndi.path=jdbc/XP
#torque.dsfactory.default.jndi.java.naming.factory.initial =
org.apache.naming.java.javaURLContextFactory
#torque.dsfactory.default.jndi.java.naming.factory.url.pkgs =
org.apache.naming
#torque.dsfactory.default.datasource.classname=org.apache.commons.jdbc2p
ool.TorqueClassicDataSource
#torque.dsfactory.default.datasource.dataSourceName=jdbc/XP
#torque.dsfactory.default.datasource.jndiEnvironment.java.naming.factory
.initial = org.apache.naming.java.javaURLContextFactory
#torque.dsfactory.default.datasource.jndiEnvironment.java.naming.factory
.url.pkgs = org.apache.naming
#torque.dsfactory.default.datasource.defaultMaxConnections=10
#
torque.dsfactory.XP.datasource.classname=org.apache.commons.jdbc2pool.To
rqueClassicDataSource
#torque.dsfactory.XP.datasource.classname=org.apache.torque.dsfactory.To
rqueDataSourceFactory
#torque.dsfactory.XP.datasource.dataSourceName=jdbc/XP
#torque.dsfactory.XP.datasource.jndiEnvironment.java.naming.factory.init
ial = org.apache.naming.java.javaURLContextFactory
#torque.dsfactory.XP.datasource.jndiEnvironment.java.naming.factory.url.
pkgs = org.apache.naming
#torque.dsfactory.XP.datasource.defaultMaxConnections=10
## ConnectionPoolDataSource
#torque.dsfactory.DBdefault.factory=org.apache.torque.dsfactory.JndiData
SourceFactory
#torque.dsfactory.DBdefault.jndi.path=jdbc/DBdefault
#torque.dsfactory.DBdefault.jndi.java.naming.factory.initial =
org.apache.naming.java.javaURLContextFactory
#torque.dsfactory.DBdefault.jndi.java.naming.factory.url.pkgs =
org.apache.naming
#torque.dsfactory.DBdefault.datasource.classname=org.apache.commons.jdbc
2pool.adapter.DriverAdapterCPDS
#torque.dsfactory.DBdefault.datasource.driver = org.gjt.mm.mysql.Driver
#torque.dsfactory.DBdefault.datasource.url =
jdbc:mysql://localhost:3306/torque
#torque.dsfactory.DBdefault.datasource.user = user
#torque.dsfactory.DBdefault.datasource.password = password
# Determines if the quantity column of the IDBroker's id_table should
# be increased automatically if requests for ids reaches a high
# volume.
torque.idbroker.cleverquantity=true
--------- END Torque.properties -----------
If you want the details of the JNDI setup on the Tomcat side I can send
those through as well. It follows the Tutorial very closely though.
This poses other questions:
When using Torque with app servers such as Tomcat, is the JNDI setup the
preferred method?
Thanks so much for your help on this. It's a great tool...I just wish I
could get it going!
Steve
-----Original Message-----
From: John McNally [mailto:[EMAIL PROTECTED]]
Sent: Saturday, 27 July 2002 9:32 AM
To: Turbine Torque Users List
Subject: Re: Tomcat/struts/torque DataSource config error
You will need to show the property arrangements you have tried. And how
are you getting torque initialized.
john mcnally
On Tue, 2002-07-23 at 22:07, Steven Wells wrote:
> I'm using:
> jakarta-tomcat-4.1.7-LE-jdk14
> torque-3.0-b3
> mm.mysql-2.0.14
> jakarta-struts-1.1-b1
> jdk1.4
> mySQL
>
> Bleeding edge I know.
>
> When I do this:
> story.save(); // story is my torque generated obj
>
> I get this (in the Tomcat console):
> Start+44725ms INFO AddStoryForm- Saving story: Steves Story
> Start+44785ms WARN IDBroker- IDBroker is being used with db 'XP',
which
> does not
> support transactions. IDBroker attempts to use transactions to limit
> the possi
> bility of duplicate key generation. Without transactions, duplicate
key
> generat
> ion is possible if multiple JVMs are used or other means are used to
> write to th
> e database.
> Start+44805ms INFO IDBroker- IDBroker thread was started.
> Start+44825ms ERROR AddStoryForm- Could not save story
> java.lang.NullPointerException: There was no DataSourceFactory
> configured for th
> e connection XP
> at org.apache.torque.Torque.getConnection(Torque.java:900)
> at
> org.apache.torque.util.BasePeer.beginTransaction(BasePeer.java:368)
> at org.xp.story.BaseStory.save(BaseStory.java:445)
> at org.xp.story.BaseStory.save(BaseStory.java:429)
> at org.xp.story.AddStoryForm.validate(AddStoryForm.java:56)
> at
> org.apache.struts.action.RequestProcessor.processValidate(RequestProc
> essor.java:910)
> at
> org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
> va:245)
> at
> org.apache.struts.action.ActionServlet.process(ActionServlet.java:110
> 9)
> at
> org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:470)
>
> at
javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
> at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>
> ETC etc etc..
>
> I've tried quite a few things, including:
>
> 1. Making sure all the .jars are in the right place.
> jndi-datasource-examples-howto.html says to put mm.mysql driver, DBCP,
> collections and pool jarfiles into $CATALINA_HOME/common/lib.
>
> 2. Editing Torque.properties like mad:
> Following the Torque tutorial using the torque.database. properties,
the
> jdbc2pool config, and JNDI (following the jdbc2pool-howto.html Torque
> doc)
>
> 3. Using idbroker, native and none as the schema defaultIdMethod.
>
> So before I delve into the source, can anyone help?
>
> Thanks.
>
> Steve
>
>
--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>