jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Diego Rodriguez" <drodrig...@altiria.com>
Subject java.sql.SQLException: Cannot load JDBC driver class 'null'
Date Tue, 14 Oct 2003 11:37:40 GMT
Hi,

    I'm trying to test a servlet. The servlet is doing some sql queries
through tomcat and dbcp pool connections. The servlet is working properly in
normal Tomcat enviroment, but when trying to test with cactus, I'm getting
the following exception:

java.sql.SQLException: Cannot load JDBC driver class 'null'
     at
org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.jav
a:529)
     at
org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:3
12)
     at
com.pirlango.runi.gateway.PushGatewayServlet.processRequest(PushGatewayServl
et.java:135)
     at
com.pirlango.runi.gateway.PushGatewayServlet.doPost(PushGatewayServlet.java:
224)
     at
com.pirlango.runi.gateway.TestPushWebappGateway.test1destOk(TestPushWebappGa
teway.java:86)
     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
org.apache.cactus.internal.server.ServerTestCaseDelegate.runServerTest(Serve
rTestCaseDelegate.java;org/apache/cactus/util/log/LogAspect.aj[1k]:214)
     at org.apache.cactus.ServletTestCase.runTest(ServletTestCase.java:280)
     at org.apache.cactus.ServletTestCase.runBare(ServletTestCase.java:251)
     at
org.apache.cactus.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.
java:156)
     at
org.apache.cactus.server.AbstractWebTestController.dispatch133_handleRequest
(AbstractWebTestController.java;org/apache/cactus/util/log/LogAspect.aj[1k]:
130)
     at
org.apache.cactus.server.AbstractWebTestController.around133_handleRequest(A
bstractWebTestController.java;org/apache/cactus/util/log/LogAspect.aj[1k]:11
58)
     at
org.apache.cactus.server.AbstractWebTestController.handleRequest(AbstractWeb
TestController.java;org/apache/cactus/util/log/LogAspect.aj[1k]:101)
     at
org.apache.cactus.server.ServletTestRedirector.dispatch160_doPost(ServletTes
tRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:125)
     at
org.apache.cactus.server.ServletTestRedirector.around160_doPost(ServletTestR
edirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:1158)
     at
org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.
java;org/apache/cactus/util/log/LogAspect.aj[1k]:109)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:247)
     at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:193)
     at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:260)
     at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(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.ja
va:191)
     at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(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.invok
eNext(StandardPipeline.java:643)
     at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
java:170)
     at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:641)
     at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172
)
     at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(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.invok
eNext(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)

This is the servlet...I get a datasource that is not null, because the log I
get here is "Init: dataSource OK"

public void init(ServletConfig config) throws ServletException {
        super.init(config);
        try {

      Context init = new InitialContext();
      Context ctx = (Context) init.lookup("java:comp/env");
        dataSource = (org.apache.commons.dbcp.BasicDataSource)
ctx.lookup("jdbc/MktsmsDb");

      if(dataSource == null ) {
    log.fatal("Init: dataSource ERROR");
      }
      else {
    log.info("Init: dataSource OK");
      }

  }
  catch (NamingException ex) {
      throw new ServletException("Cannot retrieve java:/jdbc/MktsmsDb",ex);
  }

}


but when I try to get a connection from the datasource I get the
exception....

     conn = dataSource.getConnection(); // This is the line that throws the
exception

I think it is a classpath problem, but the driver is in the server classpath
(under WEB-INF/lib). When deploying the webapp in normal enviroment, the
Firebird driver jars (firebirdsql.jar, mini-j2ee.jar, mini-concurrent.jar)
and the dbcp jar (commons-dbcp.jar) are in CATALINA_HOME/commons/lib as it
says the configuration instructions for Firebird and Tomcat. The cactus ant
task starts a minimal configuration of Tomcat...it includes the jar files in
CATALINA_HOME/commons/lib?

am I missing something? if you need more information about my app please ask
for it...

This is the cactus ant task

 <path id="cactus.classpath">
     <pathelement location="${build.home}/test"/>
     <pathelement location="${build.home}/main/WEB-INF/classes"/>
     <pathelement location="${log4j.jar}"/>
     <pathelement location="${junit.jar}"/>
     <pathelement location="${cactus.jar}"/>
     <pathelement location="${commons-httpclient.jar}"/>
     <pathelement location="${commons-logging.jar}"/>
     <pathelement location="${aspectjrt.jar}"/>
     <pathelement location="${firebirdsql.jar}"/>
     <pathelement location="${mini-j2ee.jar}"/>
     <pathelement location="${mini-concurrent.jar}"/>
  </path>

  <cactus warfile="${build.home}/testwar/api.war" fork="yes"
failureproperty="tests.failed">
      <classpath>
       <path refid="cactus.classpath"/>
         <pathelement location="${log4j.jar}"/>
         <pathelement location="C:/j2sdkee1.3.1/lib/j2ee.jar"/>
         <pathelement location="${httpunit.jar}"/>
      </classpath>

      <containerset timeout="180000">
       <tomcat4x if="cactus.home.tomcat4x"
             dir="${cactus.home.tomcat4x}" port="${cactus.port}"
             todir="${test.reports.dir}"/>

      </containerset>
      <formatter type="brief" usefile="false"/>
      <formatter type="xml"/>
   <test name="com.pirlango.runi.gateway.TestAll"
todir="${test.reports.dir}"/>
  </cactus>

This is the test....

public void test1destOk() throws Exception{
  log.debug("Enter test1destOk");

  PushGatewayServlet servlet = new PushGatewayServlet();
  servlet.init(config);

  // Call method to test
  servlet.doPost(request,response);

 }

    Thanks

        Diego




Mime
View raw message