• Welcome to KonaKart Community Forum. Please login or sign up.
 

container's jndi connection

Started by lrkwz, April 02, 2012, 11:58:57 am

Previous topic - Next topic

lrkwz

Hello,
   I wish to configure kk so that it uses the jndi connection pool defined in the container.

I've done what described in the docs http://www.konakart.com/docs/DatabaseNotes.html#JNDIDatabaseParameters and the web app start correctly but it I define the jndi pool in the container context:

<Context allowLinking="true">
<Resource name="jdbc/konakartdb"
auth="Container"
type="javax.sql.DataSource"
password="password"
url="jdbc:mysql://localhost:3306/konakart?zeroDateTimeBehavior=convertToNull"
username="root"
driverClassName="com.mysql.jdbc.Driver"
/>
<Valve className="org.apache.catalina.valves.AccessLogValve" prefix="localhost_access_log." suffix=".log" pattern="common"/>
</Context>

and remove the lines:

#torque.dsfactory.store1.datasource.driverClassName=com.mysql.jdbc.Driver
#torque.dsfactory.store1.datasource.url=jdbc:mysql://localhost:3306/konakart?zeroDateTimeBehavior=convertToNull
#torque.dsfactory.store1.datasource.username=root
#torque.dsfactory.store1.datasource.password=password


the application won't start anymore claiming:



KonaKart V6.0.0.0-C built 9:09PM 24-Jan-2012 GMT

12:41:16.964 [main] DEBUG org.apache.torque.TorqueInstance - init(org.apache.commons.configuration.PropertiesConfiguration@1c75cff)
12:41:16.969 [main] DEBUG org.apache.torque.TorqueInstance - setConfiguration(org.apache.commons.configuration.PropertiesConfiguration@1c75cff)
12:41:16.969 [main] DEBUG org.apache.torque.TorqueInstance - initialize()
12:41:16.970 [main] DEBUG org.apache.torque.TorqueInstance - setConfiguration(org.apache.commons.configuration.SubsetConfiguration@174e78a)
12:41:16.970 [main] DEBUG org.apache.torque.TorqueInstance - initAdapters(org.apache.commons.configuration.SubsetConfiguration@174e78a)
12:41:16.992 [main] DEBUG org.apache.torque.TorqueInstance - Adding mysql -> store1 as Adapter
12:41:16.999 [main] DEBUG org.apache.torque.TorqueInstance - initDataSourceFactories(org.apache.commons.configuration.SubsetConfiguration@174e78a)
12:41:16.999 [main] DEBUG org.apache.torque.TorqueInstance - handle: store1 DataSourceFactory: org.apache.torque.dsfactory.JndiDataSourceFactory
12:41:17.003 [main] DEBUG org.apache.torque.TorqueInstance - getConfiguration() = org.apache.commons.configuration.SubsetConfiguration@174e78a
12:41:17.003 [main] DEBUG o.a.t.d.JndiDataSourceFactory - Starting initJNDI
12:41:17.003 [main] DEBUG o.a.t.d.JndiDataSourceFactory - JNDI path: jdbc/konakart-demo
12:41:17.004 [main] DEBUG o.a.t.d.JndiDataSourceFactory - Time between context lookups: 60000
12:41:17.004 [main] DEBUG o.a.t.d.JndiDataSourceFactory - Set jndi property: java.naming.factory.initial=org.apache.naming.java.javaURLContextFactory
12:41:17.009 [main] DEBUG o.a.t.d.JndiDataSourceFactory - Created new InitialContext
12:41:17.009 [main] DEBUG o.a.t.d.JndiDataSourceFactory - InitialContext -------------------------------
12:41:17.009 [main] DEBUG o.a.t.d.JndiDataSourceFactory - Environment properties:2
12:41:17.009 [main] DEBUG o.a.t.d.JndiDataSourceFactory -     java.naming.factory.initial: org.apache.naming.java.javaURLContextFactory
12:41:17.009 [main] DEBUG o.a.t.d.JndiDataSourceFactory -     java.naming.factory.url.pkgs: org.apache.naming
12:41:17.009 [main] DEBUG o.a.t.d.JndiDataSourceFactory - ----------------------------------------------
12:41:17.009 [main] DEBUG o.a.t.d.JndiDataSourceFactory - Starting initDataSource
12:41:17.010 [main] DEBUG o.a.t.d.JndiDataSourceFactory - Datasource class: org.apache.commons.dbcp.BasicDataSource
12:41:17.089 [main] DEBUG o.a.t.d.JndiDataSourceFactory - InitialContext -------------------------------
12:41:17.090 [main] DEBUG o.a.t.d.JndiDataSourceFactory - Environment properties:2
12:41:17.090 [main] DEBUG o.a.t.d.JndiDataSourceFactory -     java.naming.factory.initial: org.apache.naming.java.javaURLContextFactory
12:41:17.090 [main] DEBUG o.a.t.d.JndiDataSourceFactory -     java.naming.factory.url.pkgs: org.apache.naming
12:41:17.090 [main] DEBUG o.a.t.d.JndiDataSourceFactory - ----------------------------------------------
12:41:17.090 [main] DEBUG o.a.t.d.JndiDataSourceFactory - Added sub context: jdbc
12:41:17.091 [main] DEBUG org.apache.torque.TorqueInstance - Adding the DatasourceFactory and DatabaseAdapter from database store1 onto database default
com.konakart.app.KKException: Unable to connect to the Database called null. Ensure that the database is running
and if so, check the database connection parameters in the konakart.properties file under WEB-INF/classes.


Any suggestions?

iahmed

In your logs you had

12:41:17.003 [main] DEBUG o.a.t.d.JndiDataSourceFactory - JNDI path: jdbc/konakart-demo


and the jndi you specified was jdbc/konakartdb

I believe in your properties you need to specify where store1 is database default

torque.dsfactory.store1.factory              = org.apache.torque.dsfactory.JndiDataSourceFactory
torque.dsfactory.store1.jndi.path            = jdbc/konakartdb
torque.dsfactory.store1.jndi.ttl             = 60000
torque.dsfactory.store1.jndi.java.naming.factory.initial = \
                                                     org.apache.naming.java.javaURLContextFactory

comment
out

#torque.dsfactory.store1.factory=org.apache.torque.dsfactory.SharedPoolDataSourceFactory