db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pierre Henry <he...@hta-bi.bfh.ch>
Subject using torque standalone with struts- NullPointerException on save() method
Date Sun, 14 Dec 2003 20:54:40 GMT
Hi all !
I am trying to use torque for a struts web app with tomcat.

I could generate the sql schema and OM classes without any problem.

Now, I am trying to build a new business object and to call the save 
method on it.
Thanks to other posts on this list, I know that I have to call the 
Torque.init(path) method first (right now I do it directly in the same 
method, but I will make a servlet that does this), and I added the 
connection pool settings to my Torque.properties file.

Now when I call the save method I get :

java.lang.NullPointerException: There was no DataSourceFactory 
configured for th
e connection torque
        at 
org.apache.torque.TorqueInstance.getConnection(TorqueInstance.java:74
9)
        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 singha.om.BaseMovie.save(BaseMovie.java:666)
        at singha.om.BaseMovie.save(BaseMovie.java:647)
        at singha.om.utils.Tester.createMovieInDB(Tester.java:38)
        at 
singha.actions.CreateMovieAction.perform(CreateMovieAction.java:50)
        at org.apache.struts.action.Action.execute(Action.java:420)
        at 
org.apache.struts.action.RequestProcessor.processActionPerform(Reques
tProcessor.java:484)

The thing is that I don't want to use a connection called torque, but my 
connection called "singha" as defined in my props file. So the problem 
seems to be that torque does not use the connection specified but some 
default called torque (?).

I am a newbie so I guess I could be missing something obvious, many 
thanks if you can help me !

Pierre Henry
Biel School of Engineering



Here I join my props file and the log of the Torque.init() call :

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 = singha
torque.database.singha.driver = oracle.jdbc.driver.OracleDriver
torque.database.singha.url = jdbc:oracle:thin:@localhost:1521:orcl
torque.database.singha.username = singha
torque.database.singha.password = ...
torque.dsfactory.singha.factory=org.apache.torque.dsfactory.TorqueDataSourceFactory

torque.dsfactory.singha.pool.defaultMaxConnections=10
torque.dsfactory.singha.pool.maxExpiryTime=3600
torque.dsfactory.singha.pool.connectionWaitTimeout=10
torque.dsfactory.singha.connection.driver = oracle.jdbc.driver.OracleDriver
torque.dsfactory.singha.connection.url = 
jdbc:oracle:thin:@localhost:1521:orcl
torque.dsfactory.singha.connection.user = singha
torque.dsfactory.singha.connection.password =  ...
torque.database.singha.adapter = oracle
torque.singha.connection.driver = oracle.jdbc.driver.OracleDriver

_________________________________________________________________
Torque.init() Log :

[DEBUG] TorqueInstance - 
-init(C:\Home\java\webtech\singha\web\WEB-INF\Torque.pr
operties)
[DEBUG] TorqueInstance - -Config Object is 
org.apache.commons.configuration.Prop
ertiesConfiguration@146b6db
[DEBUG] TorqueInstance - 
-init(org.apache.commons.configuration.PropertiesConfig
uration@146b6db)
[DEBUG] TorqueInstance - 
-setConfiguration(org.apache.commons.configuration.Prop
ertiesConfiguration@146b6db)
[DEBUG] TorqueInstance - -initialize()
[DEBUG] TorqueInstance - 
-setConfiguration(org.apache.commons.configuration.Base
Configuration@18f1be9)
[DEBUG] TorqueInstance - 
-initAdapters(org.apache.commons.configuration.BaseConf
iguration@18f1be9)
[DEBUG] TorqueInstance - -Adding oracle -> singha as Adapter
[DEBUG] TorqueInstance - 
-initDataSourceFactories(org.apache.commons.configurati
on.BaseConfiguration@18f1be9)
[DEBUG] TorqueInstance - -handle: singha DataSourceFactory: 
org.apache.torque.ds
factory.TorqueDataSourceFactory
[DEBUG] AbstractDataSourceFactory - -Starting initCPDS
[DEBUG] TorqueInstance - -getConfiguration() = 
org.apache.commons.configuration.
BaseConfiguration@18f1be9
[DEBUG] AbstractDataSourceFactory - -applyConfiguration(null, 
org.apache.commons
.dbcp.cpdsadapter.DriverAdapterCPDS@4ab2f)
[DEBUG] AbstractDataSourceFactory - 
-applyConfiguration(org.apache.commons.confi
guration.BaseConfiguration@82d210, 
org.apache.commons.dbcp.cpdsadapter.DriverAda
pterCPDS@4ab2f)
[DEBUG] ConvertUtils - -Convert string 'oracle.jdbc.driver.OracleDriver' 
to clas
s 'java.lang.String'
[DEBUG] AbstractDataSourceFactory - 
-setSimpleProperty(org.apache.commons.dbcp.c
pdsadapter.DriverAdapterCPDS@4ab2f, driver, oracle.jdbc.driver.OracleDriver)
[DEBUG] ConvertUtils - -Convert string 
'jdbc:oracle:thin:@localhost:1521:orcl' t
o class 'java.lang.String'
[DEBUG] AbstractDataSourceFactory - 
-setSimpleProperty(org.apache.commons.dbcp.c
pdsadapter.DriverAdapterCPDS@4ab2f, url, 
jdbc:oracle:thin:@localhost:1521:orcl)
[DEBUG] ConvertUtils - -Convert string 'singha' to class 'java.lang.String'
[DEBUG] AbstractDataSourceFactory - 
-setSimpleProperty(org.apache.commons.dbcp.c
pdsadapter.DriverAdapterCPDS@4ab2f, user, singha)
[DEBUG] ConvertUtils - -Convert string 'shangai' to class 'java.lang.String'
[DEBUG] AbstractDataSourceFactory - 
-setSimpleProperty(org.apache.commons.dbcp.c
pdsadapter.DriverAdapterCPDS@4ab2f, password, shangai)
[DEBUG] TorqueDataSourceFactory - -Starting initTorqueClassic
[DEBUG] TorqueInstance - -getConfiguration() = 
org.apache.commons.configuration.
BaseConfiguration@18f1be9
[DEBUG] AbstractDataSourceFactory - -applyConfiguration(null, 
org.apache.torque.
pool.TorqueClassicDataSource@1e46a68)
[DEBUG] AbstractDataSourceFactory - 
-applyConfiguration(org.apache.commons.confi
guration.BaseConfiguration@105eb6f, 
org.apache.torque.pool.TorqueClassicDataSour
ce@1e46a68)
[DEBUG] ConvertUtils - -Convert string '10' to class 'int'
[DEBUG] AbstractDataSourceFactory - 
-setSimpleProperty(org.apache.torque.pool.To
rqueClassicDataSource@1e46a68, defaultMaxConnections, 10)
[DEBUG] ConvertUtils - -Convert string '3600' to class 'int'
[DEBUG] AbstractDataSourceFactory - 
-setSimpleProperty(org.apache.torque.pool.To
rqueClassicDataSource@1e46a68, maxExpiryTime, 3600)
[DEBUG] ConvertUtils - -Convert string '10' to class 'int'
[DEBUG] AbstractDataSourceFactory - 
-setSimpleProperty(org.apache.torque.pool.To
rqueClassicDataSource@1e46a68, connectionWaitTimeout, 10)
[DEBUG] TorqueInstance - -Adding a dummy entry for default, mapped onto 
singha
[DEBUG] TorqueInstance - -getConfiguration() = 
org.apache.commons.configuration.
BaseConfiguration@18f1be9
[WARN] IDBroker - -IDBroker is being used with db 'torque', which does 
not suppo
rt transactions. IDBroker attempts to use transactions to limit the 
possibility
of duplicate key generation.  Without transactions, duplicate key 
generation is
possible if multiple JVMs are used or other means are used to write to 
the datab
ase.
[DEBUG] IDBroker - -IDBroker thread was started.


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