jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vincent Massol" <vmas...@pivolis.com>
Subject RE: java.sql.SQLException: Cannot load JDBC driver class 'null'
Date Sat, 29 Nov 2003 20:00:27 GMT
Hi Diego,

The Cactus framework does not install anything. It doesn't even cactify
your war. This is up to you. However, Cactus has several front ends that
do this work for you. Are you talking about the Ant <cactus> task when
you say " I don't know how Cactus installs the cactified wars to run the
tests"?

What I can tell you is that the <cactus> task provides default Tomcat
config files. The webapp is defined in the default server.xml. You can
however provide your own server.xml. The <cactus> task does not use
context.xml.

Thanks
-Vincent

> -----Original Message-----
> From: Diego Rodriguez [mailto:drodriguez@altiria.com]
> Sent: 21 October 2003 15:39
> To: Cactus Users List
> Subject: Re: java.sql.SQLException: Cannot load JDBC driver class
'null'
> 
> Hi all,
> 
>     I found the solution...
> 
>     Deploying the cactified war with Tomcat manager app, it uses the
> context.xml file under META-INF to set the context in server.xml, and
then
> I
> use this server.xml to start Tomcat with the cactus ant task.
> 
>     The only thing that I'm not happy with is that this server.xml has
a
> static docBase where the cactified war is.
> 
>     I don't know how Cactus installs the cactified wars to run the
tests,
> but if the cactified war has a context.xml in META-INF with some
resources
> the test are not running properly, because the app is not installed as
it
> is
> installed with Tomcat install or deploy manager apps using
context.xml.
> The
> solution is setting the context in server.xml so the resources can be
> found,
> but I think Cactus "should" install it properly by itself if
context.xml
> is
> under META-INF...Correct me if I'm wrong or if I've misunderstood
Cactus
> framework, please, because this is only a suggestion...
> 
>     Diego
> 
> 
> ----- Original Message -----
> From: "Diego Rodriguez" <drodriguez@altiria.com>
> To: "Cactus Users List" <cactus-user@jakarta.apache.org>
> Sent: Thursday, October 16, 2003 4:18 PM
> Subject: Re: java.sql.SQLException: Cannot load JDBC driver class
'null'
> 
> 
> > 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" <drodriguez@altiria.com>
> > To: <cactus-user@jakarta.apache.org>
> > 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
.j
> av
> > > a:529)
> > >      at
> > >
> >
>
org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.ja
va
> :3
> > > 12)
> > >      at
> > >
> >
>
com.pirlango.runi.gateway.PushGatewayServlet.processRequest(PushGatewayS
er
> vl
> > > et.java:135)
> > >      at
> > >
> >
>
com.pirlango.runi.gateway.PushGatewayServlet.doPost(PushGatewayServlet.j
av
> a:
> > > 224)
> > >      at
> > >
> >
>
com.pirlango.runi.gateway.TestPushWebappGateway.test1destOk(TestPushWeba
pp
> Ga
> > > teway.java:86)
> > >      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
> > >      at
> > >
> >
>
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:
> 39
> > > )
> > >      at
> > >
> >
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Im
> pl
> > > java:25)
> > >      at java.lang.reflect.Method.invoke(Method.java:324)
> > >      at
> > >
> >
>
org.apache.cactus.internal.server.ServerTestCaseDelegate.runServerTest(S
er
> ve
> > >
>
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(AbstractWebTestCal
le
> r.
> > > java:156)
> > >      at
> > >
> >
>
org.apache.cactus.server.AbstractWebTestController.dispatch133_handleReq
ue
> st
> > >
> >
>
(AbstractWebTestController.java;org/apache/cactus/util/log/LogAspect.aj[
1k
> ]:
> > > 130)
> > >      at
> > >
> >
>
org.apache.cactus.server.AbstractWebTestController.around133_handleReque
st
> (A
> > >
> >
>
bstractWebTestController.java;org/apache/cactus/util/log/LogAspect.aj[1k
]:
> 11
> > > 58)
> > >      at
> > >
> >
>
org.apache.cactus.server.AbstractWebTestController.handleRequest(Abstrac
tW
> eb
> > >
TestController.java;org/apache/cactus/util/log/LogAspect.aj[1k]:101)
> > >      at
> > >
> >
>
org.apache.cactus.server.ServletTestRedirector.dispatch160_doPost(Servle
tT
> es
> > > tRedirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:125)
> > >      at
> > >
> >
>
org.apache.cactus.server.ServletTestRedirector.around160_doPost(ServletT
es
> tR
> > > edirector.java;org/apache/cactus/util/log/LogAspect.aj[1k]:1158)
> > >      at
> > >
> >
>
org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirec
to
> r.
> > > 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(Applica
ti
> on
> > > FilterChain.java:247)
> > >      at
> > >
> >
>
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
er
> Ch
> > > ain.java:193)
> > >      at
> > >
> >
>
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
e.
> ja
> > > va:260)
> > >      at
> > >
> >
>
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nv
> ok
> > > eNext(StandardPipeline.java:643)
> > >      at
> > >
> >
>
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
80
> )
> > >      at
> > >
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> > >      at
> > >
> >
>
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv
e.
> ja
> > > va:191)
> > >      at
> > >
> >
>
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nv
> ok
> > > eNext(StandardPipeline.java:643)
> > >      at
> > >
> >
>
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
80
> )
> > >      at
> > >
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> > >      at
> > >
>
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:241
5)
> > >      at
> > >
> >
>
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
:1
> 80
> > > )
> > >      at
> > >
> >
>
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nv
> ok
> > > eNext(StandardPipeline.java:643)
> > >      at
> > >
> >
>
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherVa
lv
> e.
> > > java:170)
> > >      at
> > >
> >
>
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nv
> ok
> > > eNext(StandardPipeline.java:641)
> > >      at
> > >
> >
>
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
:1
> 72
> > > )
> > >      at
> > >
> >
>
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nv
> ok
> > > eNext(StandardPipeline.java:641)
> > >      at
> > >
> >
>
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
80
> )
> > >      at
> > >
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> > >      at
> > >
> >
>
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
ja
> va
> > > :174)
> > >      at
> > >
> >
>
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nv
> ok
> > > eNext(StandardPipeline.java:643)
> > >      at
> > >
> >
>
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
80
> )
> > >      at
> > >
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> > >      at
> > >
> >
>
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.j
av
> a:
> > > 1040)
> > >      at
> > >
> >
>
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:
11
> 51
> > > )
> > >      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
> > >
> > >
> > >
> > >
> > >
---------------------------------------------------------------------
> > > To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail:
cactus-user-help@jakarta.apache.org
> > >
> > >
> > >
> >
> >
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: cactus-user-help@jakarta.apache.org
> >
> >
> >
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org



Mime
View raw message