OK, after numerous hacks, my software is functioning! Now I just need to cache the DB connections and I am home free ;-).

Unfortunately, as usual, this is giving me more problems than expected.

So far, I have done the following:

added:

<resource-ref>
 <description>Oracle Datasource example</description>
 <res-ref-name>jdbc/grinpal</res-ref-name>
 <res-type>javax.sql.DataSource</res-type>
 <res-auth>Container</res-auth>
</resource-ref>

inside the <web-app> token in /usr/share/tomcat5/webapps/axis2/WEB-INF/web.xml

added a context file /usr/share/tomcat5/webapps/axis2/META-INF/context.xml:

<?xml version='1.0' encoding='utf-8'?>
<Context path="/axis2" debug="5" reloadable="true" docBase='${catalina.home}/server/webapps/axis2'>

<Resource name="jdbc/grinpal" auth="Container" type="javax.sql.DataSource"/>

    <ResourceParams name="jdbc/grinpal">
      <parameter>
         <name>factory</name>
         <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
      </parameter>
      <parameter>
         <name>driverClassName</name>
         <value>oracle.jdbc.driver.OracleDriver</value>
      </parameter>
      <parameter>
         <name>url</name>
         <value>jdbc:oracle:thin:@//172.xxx.xxx.xxx:1521/orcl</value>
      </parameter>
      <parameter>
         <name>username</name>
         <value>XXXXXXX</value>
      </parameter>
      <parameter>
        <name>password</name>
        <value>XXXXXX</value>
      </parameter>
      <parameter>
        <name>maxActive</name>
        <value>20</value>
      </parameter>
      <parameter>
        <name>maxIdle</name>
        <value>10</value>
      </parameter>
      <parameter>
        <name>maxWait</name>
        <value>-1</value>
      </parameter>
    </ResourceParams>

</Context>

And added the code:

System.out.println("connecting to db");
javax.naming.Context initContext =
        new javax.naming.InitialContext();
System.out.println("got init");
javax.naming.Context envContext =
        (javax.naming.Context)initContext.lookup("java:/comp/env");
System.out.println("got env");
javax.sql.DataSource ds =
        (javax.sql.DataSource)envContext.lookup("jdbc/grinpal");
System.out.println("got ds");
Connection conn = ds.getConnection();
System.out.println("connected to db");
stmt = dbConn.createStatement();
res = stmt.executeQuery("select switch_address, title, initials, surname, street_number, street_name from customer where card_nr="+cardNr);


to my webservice.  In theory, this should work, but I get:
connecting to db
got init
got env
got ds
Error querying customer db: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'



Obviously, it is not retrieving the parameters correctly... I tried moving context.xml out, and this results in the same error. So it seems my context.xml is not being loaded, or is incorrect. Anybody have any ideas?

Thanks,

Justin

Reply via email to