tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 15672] - DBCP doesn't work on Tomcat 4.1.18 with Oracle JDBC driver
Date Fri, 13 Jun 2003 21:07:26 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15672>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15672

DBCP doesn't work on Tomcat 4.1.18 with Oracle JDBC driver





------- Additional Comments From mholly@talisentech.com  2003-06-13 21:07 -------
In trying to make the move to automate my testing I have come up
against the same problem.

First some background.
I am running Tomcat 4.1.18, Java 1.3.1, Win 2k

classes12.jar, commons-collections.jar, 
commons-dbcp.jar, commons-pool are located 
in $TOMCAT_HOME/common/lib

I am attempting to get automated testing running
To do this was getting the ANT build
to undeploy and then redeploy the war after it got created.
In addition, I decided that it was more convenient to have the
Test classes located in my app.war instead of a seperate war.

Part of getting this dynamic undeploy/deploy cycle to work was
removing the <context> from the server.xml. The reason I want to
do this is I have 2 connection pools located there. In a dynamic
deploy tomcat generates it's own context for the app. I found there
were three ways I could do this.

#1. put the connection pool into the <GlobalNamingResources> section
    of server.xml

#2. create a $APP_NAME.xml file that contains the context of the app
    and put it into $TOMCAT_HOME/webapps. Both the Tomcat manager and
    Admin apps do this.

#3. Possibly put the context info in the web.xml file for the app.

I have tried both 1 and 2 and I am getting the
java.sql.SQLException: Cannot load JDBC driver class 'null' error
when the DBCP is accessed in both.

Below are the relevant files for Option #2

WEB.XML-------------------------------------------------------------------------
------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 
2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
    <display-name>TSR Application</display-name>
    <description>This is the web configuration for the TSR 
application</description>

<!-- SERVLET LISTINGS -->
    <servlet>
        <servlet-name>TestServlet</servlet-name>
        <servlet-class>net.myco.myapp.servlets.TestServlet</servlet-class>
    </servlet>

    <servlet>
        <servlet-name>ControllerServlet</servlet-name>
        <servlet-class>net.myco.myapp.servlets.ControllerServlet</servlet-class>
    </servlet>
    
    <servlet>
        <servlet-name>FileDownloadServlet</servlet-name>
        <servlet-class>net.myco.myapp.servlets.FileDownloadServlet</servlet-
class>
    </servlet>
    
    <servlet>
       <servlet-name>StartupServlet</servlet-name>
       <servlet-class>net.myco.myapp.servlets.StartupServlet</servlet-class>
       <load-on-startup>1</load-on-startup>
    </servlet>
    
    <!--servlet>
        <servlet-name>log4j-init</servlet-name>
        <servlet-class>net.myco.myapp.servlets.Log4jInit</servlet-class>
        <load-on-startup>1</load-on-startup>
        <init-param>
           <param-name>log4j-init-file</param-name>
           <param-value>WEB-INF\classes\log4j.properties</param-value>
        </init-param>
    </servlet-->

    <!-- integrate the testing -->
    <servlet>
      <servlet-name>JUnitEETestServlet</servlet-name>
      <description>JUnitEE test runner</description>
      <servlet-class>org.junitee.servlet.JUnitEEServlet</servlet-class>
    </servlet>

<!-- SERVLET MAPPINGS -->
    <servlet-mapping>
        <servlet-name>TestServlet</servlet-name>
        <url-pattern>/test</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>StartupServlet</servlet-name>
        <url-pattern>/startup</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>ControllerServlet</servlet-name>
        <url-pattern>/controller</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>FileDownloadServlet</servlet-name>
        <url-pattern>/download</url-pattern>
    </servlet-mapping>

    <!-- integrate the testing -->
    <servlet-mapping>
      <servlet-name>JUnitEETestServlet</servlet-name>
      <url-pattern>/TestServlet/*</url-pattern>
    </servlet-mapping>
          
<!-- JNDI resource for DB connection pool -->
    <resource-ref>
      <description>
       Resource reference to a factory for java.sql.Connection
       instances that may be used for talking to a particular
       database that is configured in the server.xml file.
      </description>

      <res-ref-name>
         jdbc/oracle_myapp
      </res-ref-name>
      <res-type>
         javax.sql.DataSource
      </res-type>
      <res-auth>
         Container
      </res-auth>
   </resource-ref>          
          

<!-- JNDI resource for DB connection pool -->
    <resource-ref>
      <description>
       Resource reference to a factory for java.sql.Connection
       instances that may be used for talking to a particular
       database that is configured in the server.xml file.
      </description>

      <res-ref-name>
         jdbc/oracle_myco
      </res-ref-name>
      <res-type>
         javax.sql.DataSource
      </res-type>
      <res-auth>
         Container
      </res-auth>
   </resource-ref>                   
</web-app>
WEB.XML-------------------------------------------------------------------------
------------


TSR.XML-------------------------------------------------------------------------
------------
        <Context path="/myapp" docBase="myapp.war" debug="3" reloadable="true" 
crossContext="true">  
           <Loader checkInterval="6"/>
           <Logger className="org.apache.catalina.logger.FileLogger"
                      prefix="localhost_myappdb_log." 
                      suffix=".txt"
                   timestamp="true"/>
  
           <Resource name="jdbc/oracle_myapp" auth="Container"
           type="javax.sql.DataSource"/> 

           <ResourceParams name="jdbc/oracle_myapp">
              <parameter>
                 <name>factory</name>
                 <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
              </parameter>
              <parameter>
                 <name>driverClassName</name>
                 <value>oracle.jdbc.OracleDriver</value>     
              </parameter>
              <parameter>
                 <name>url</name>
                 <!--value>jdbc:oracle:thin:@myserver:1521:myco</value-->
                 <value>jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS_LIST = 
(ADDRESS = (PROTOCOL = TCP)(HOST = myserver.myco.com)(PORT = 1521))) 
(CONNECT_DATA = (SERVER = DEDICATED) (SID = MYCO)))</value>      
              </parameter>
              <parameter>
                 <name>username</name>
                 <value>myapp</value>
              </parameter>
              <parameter>
                 <name>password</name>
                 <value>actuator</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>
              <parameter>
                 <name>validationQuery</name>
                 <value>select 'validationQuery' from dual</value>
              </parameter>
              <parameter>
                 <name>testOnBorrow</name>
                 <value>true</value>
              </parameter>    
           </ResourceParams>

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

           <ResourceParams name="jdbc/oracle_myco">
              <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:@myserver:1521:myco</value-->
                 <value>jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS_LIST = 
(ADDRESS = (PROTOCOL = TCP)(HOST = myserver.myco.com)(PORT = 1521))) 
(CONNECT_DATA = (SERVER = DEDICATED) (SID = MYCO)))</value>      
              </parameter>
              <parameter>
                 <name>username</name>
                 <value>myco</value>
              </parameter>
              <parameter>
                 <name>password</name>
                 <value>myco</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>
              <parameter>
                 <name>validationQuery</name>
                 <value>select 'validationQuery' from dual</value>
              </parameter>
              <parameter>
                 <name>testOnBorrow</name>
                 <value>true</value>
              </parameter>    
           </ResourceParams>
        </Context>
TSR.XML-------------------------------------------------------------------------
------------


My log even shows the look up of the datasource in the context

2003-06-13 13:42:51,009 DEBUG  myapp.DBCmd 208  - Looking up db
2003-06-13 13:42:51,009 DEBUG  myapp.DBCmd 214  - Getting connection to 
java:/comp/env/jdbc/oracle_myapp
2003-06-13 13:42:51,019 ERROR  myapp.DBCmd 234  - SQL EXCEPTIONCannot load JDBC 
driver class 'null'

java.sql.SQLException: Cannot load JDBC driver class 'null'
        at org.apache.commons.dbcp.BasicDataSource.createDataSource
(BasicDataSource.java:529)
        at org.apache.commons.dbcp.BasicDataSource.getConnection
(BasicDataSource.java:312)
        at net.myco.myapp.DBCmd.open(DBCmd.java:219)
        at net.myco.myapp.DBCmd.open(DBCmd.java:186)
        at net.myco.myapp.model.customer.Customer.<init>(Customer.java:70)
        at test.myco.myapp.model.customer.CustomerTest.testCustomer
(CustomerTest.java:74)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at junit.framework.TestCase.runTest(TestCase.java:154)
        at junit.framework.TestCase.runBare(TestCase.java:127)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at org.junitee.runner.TestRunner$1.run(TestRunner.java:72)
        at org.junitee.runner.TestRunner.run(TestRunner.java:95)
        at org.junitee.servlet.JUnitEEServlet.runTests(JUnitEEServlet.java:224)
        at org.junitee.servlet.JUnitEEServlet.doGet(JUnitEEServlet.java:195)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:247)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:260)
        at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.
java:643)
        at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:480)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:191)
        at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.
java:643)
        at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:480)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at org.apache.catalina.core.StandardContext.invoke
(StandardContext.java:2415)
        at org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:180)
        at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.
java:643)
        at org.apache.catalina.valves.ErrorDispatcherValve.invoke
(ErrorDispatcherValve.java:170)
        at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.
java:641)
        at org.apache.catalina.valves.ErrorReportValve.invoke
(ErrorReportValve.java:172)
        at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.
java:641)
        at org.apache.catalina.valves.AccessLogValve.invoke
(AccessLogValve.java:509)
        at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.
java:641)
        at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:480)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:174)
        at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.
java:643)
        at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:480)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at org.apache.catalina.connector.http.HttpProcessor.process
(HttpProcessor.java:1040)
        at org.apache.catalina.connector.http.HttpProcessor.run
(HttpProcessor.java:1151)
        at java.lang.Thread.run(Thread.java:536)
2003-06-13 13:42:51,179 ERROR              customer.Customer 139  - Customer 
was not able to be added.

Thanks for the help

Michael

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message