Return-Path: list-help: list-unsubscribe: List-Post: List-Id: Mailing-List: contact cactus-user-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list cactus-user@jakarta.apache.org Received: (qmail 13898 invoked from network); 16 Oct 2003 14:18:37 -0000 Received: from unknown (HELO Altiria-Mobile) (80.28.121.86) by daedalus.apache.org with SMTP; 16 Oct 2003 14:18:37 -0000 Message-ID: <011001c393f0$5f4aaf30$1802a8c0@AltiriaMobile> From: "Diego Rodriguez" To: "Cactus Users List" References: <038b01c39247$93456dc0$1802a8c0@AltiriaMobile> Subject: Re: java.sql.SQLException: Cannot load JDBC driver class 'null' Date: Thu, 16 Oct 2003 16:18:29 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Server: mini-Relay v0.9.65 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi, I've done more testing in my app, and I have more information... - When getting a connection not using dbcp datasource, everything works fine, so I guess it must be a jndi problem - I've read that accessing my test servlet as http://localhost/test instead of http://localhost/myapp is a bit different. /test knows about resources in the proper context. /myapp do not. And when trying to get the datasource from jndi in this situation it throws a java.sql.SQLException: Cannot load JDBC driver class 'null'. - I'm using a separate context.xml file to set context and the datasource resource, and it is in the cactified war under META-INF dir, and I guess here it is the problem, because it has no references to the new /test context... the resources in this context.xml should be "cactified" also, so the application to be tested could get them? should I move this resource to another place? what else can I do? Thanks Diego ----- Original Message ----- From: "Diego Rodriguez" To: Sent: Tuesday, October 14, 2003 1:37 PM Subject: java.sql.SQLException: Cannot load JDBC driver class 'null' > 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 > > > > > > > > > > > > > > > > failureproperty="tests.failed"> > > > > > > > > > dir="${cactus.home.tomcat4x}" port="${cactus.port}" > todir="${test.reports.dir}"/> > > > > > todir="${test.reports.dir}"/> > > > 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 > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: cactus-user-help@jakarta.apache.org > > >