tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cox, Charlie" <c...@cincom.com>
Subject RE: loading jdbc driver fails from DataSource and Context - class Loader problem??
Date Tue, 17 Dec 2002 20:59:34 GMT
is your mysql jar file in /common/lib instead of in /WEB-INF/lib?

Charlie

> -----Original Message-----
> From: Paul Tomsic [mailto:ptomsic@yahoo.com]
> Sent: Tuesday, December 17, 2002 3:37 PM
> To: tomcat-user@jakarta.apache.org
> Subject: loading jdbc driver fails from DataSource and Context -
> classLoader problem??
> 
> 
> Why does the following work:
> 
> Class.forName("com.mysql.jdbc.Driver").newInstance();
> Connection conn =
> DriverManager.getConnection("jdbc:mysql://10.117.7.18:3306/dow
> ?autoReconnect=true",
> "user", "pwd");
> PreparedStatement t_stm =
> conn.prepareStatement("select name from templates");
> ResultSet t_rs = t_stm.executeQuery();
> while(t_rs.next()) {
>    out.println(t_rs.getString(1));
> }			
> 			
> But the following code fails with 
> "java.sql.SQLException: Cannot load JDBC driver class
> 'null'" :
> 		
> System.setProperty("jdbc.drivers",
> "com.mysql.jdbc.Driver");
> Context t_ctx = new InitialContext();
> DataSource t_ds =
> (DataSource)t_ctx.lookup("java:comp/env/jdbc/DOW");
> Connection t_conn = t_ds.getConnection();
> PreparedStatement t_stm =
> t_conn.prepareStatement("select name from templates");
> ResultSet t_rs = t_stm.executeQuery();
> while (t_rs.next()){
>   out.println(t_rs.getString(1));
> }
> 
> I've got this in my server.xml:
> 
> -----
>     <Resource name="jdbc/dow" auth="Container"
> type="javax.sql.DataSource"/>
>     <ResourceParams name="jdbc/DOW">
>     	<parameter>
>     		<name>factory</name>
>     	
> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>     	</parameter>
>     	<parameter>
>     		<name>removeAbandoned</name>
>     		<value>true</value>
>     	</parameter>
>     	<parameter>
>     		<name>removeAbandonedTimeout</name>
>     		<value>60</value>
>     	</parameter>
>     	<parameter>
>     		<name>logAbandoned</name>
>     		<value>true</value>
>     	</parameter>
>     	<parameter>
>     		<name>maxActive</name>
>     		<value>100</value>
>     	</parameter>
>     	<parameter>
>     		<name>maxIdle</name>
>     		<value>30</value>
>     	</parameter>
>     	<parameter>
>     		<name>maxWait</name>
>     		<value>10000</value>
>     	</parameter>
>     	<parameter>
>     		<name>username</name>
>     		<value>usr</value>
>     	</parameter>
>     	<parameter>
>     		<name>password</name>
>     		<value>pwd</value>
>     	</parameter>
>     	<parameter>
>     		<name>driverClassName</name>
> 			<value>com.mysql.jdbc.Driver</value>
>     		
>     	</parameter>
>     	<parameter>
>     		<name>url</name>
>     	
> <value>jdbc:mysql://10.117.7.18:3306/dow?autoReconnect=true</value>
>     	</parameter>
> 	</ResourceParams> 
> -----
> 
> and my web.xml:
> -----
> 	<resource-ref>
> 		<description>DB Connection</description>
> 		<res-ref-name>jdbc/DOW</res-ref-name>
> 		<res-type>javax.sql.DataSource</res-type>
> 		<res-auth>Container</res-auth>
> 	</resource-ref>
> 
> -----
> 
> the stack trace for the error:
> -----
> java.sql.SQLException: Cannot load JDBC driver class
> 'null'
>         at
> org.apache.commons.dbcp.BasicDataSource.createDataSource(Basic
DataSource.java:529)
>         at
> org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDat
> aSource.java:312)
>         at
> com.cappsdigital.actions.dsTest.doGet(dsTest.java:50)
>         at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
>         at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilt
> er(ApplicationFilterChain.java:247)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(Appli
cationFilterChain.java:193)
>         at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardW
rapperValve.java:260)
>         at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValv
eContext.invokeNext(StandardPipeline.java:643)
>         at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipel
> ine.java:480)
>         at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
>         at
> org.apache.catalina.core.StandardContextValve.invoke(StandardC
ontextValve.java:191)
>         at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValv
eContext.invokeNext(StandardPipeline.java:643)
>         at
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(Aut
henticatorBase.java:527)
>         at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValv
eContext.invokeNext(StandardPipeline.java:641)
>         at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipel
> ine.java:480)
>         at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
>         at
> org.apache.catalina.core.StandardContext.invoke(StandardContex
> t.java:2396)
>         at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHost
> Valve.java:180)
>         at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValv
eContext.invokeNext(StandardPipeline.java:643)
>         at
> org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDi
spatcherValve.java:170)
>         at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValv
eContext.invokeNext(StandardPipeline.java:641)
>         at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReport
> Valve.java:172)
>         at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValv
eContext.invokeNext(StandardPipeline.java:641)
>         at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipel
> ine.java:480)
>         at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
>         at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEn
gineValve.java:174)
>         at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValv
eContext.invokeNext(StandardPipeline.java:643)
>         at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipel
> ine.java:480)
>         at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
>         at
> org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.
> java:223)
>         at
> org.apache.coyote.http11.Http11Processor.process(Http11Process
> or.java:405)
>         at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandle
r.processConnection(Http11Protocol.java:380)
>         at
> org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoi
> nt.java:508)
>         at
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(
ThreadPool.java:533)
>         at java.lang.Thread.run(Thread.java:491)
> 
> -----
> 
> thoughts?
> 
> 
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
> 
> --
> To unsubscribe, e-mail:   
<mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:tomcat-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message