Just to make sure that thereâs no problems with my code, I wrote the following page and tried it. TADA! I get the same goddamn error: <%@ page language="java" import="javax.naming.*, javax.sql.*, java.sql.*" %> Hello! Running DB test... <br> <% DataSource ds = (DataSource)new InitialContext().lookup("java:comp/env/jdbc/RESK"); %> DS looked up!<br> <%-- IT EXECUTED UP TO HERE. EVRYTHING WAS FINE. THEN I ADDED THE BOTTOM PART AND GOT THE âcannot create ââ ERROR! --%> Now trying to execute a query...<br> <% Connection con = ds.getConnection(); PreparedStatement st = con.prepareStatement("SELECT CURTIME()"); ResultSet rs = st.executeQuery(); rs.next(); String time = rs.getString(1); rs.close(); st.close(); con.close(); %> Time is: <%=time%> !!! <br> I just wish tomcat developers actually tested their shit before putting it out. _____
From: Ivan Jouikov [mailto:[EMAIL PROTECTED] Sent: Sunday, July 11, 2004 9:28 PM To: 'Tomcat Users List' Subject: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' When they compiled the latest âstableâ Tomcat, did they bother to test it before putting it out? I looke through the entire google, and through this entire list, and I found lots of people having this problem. Yet, I didnât find any solutions (that worked for me that is). Basically, hereâs what I have: Iâm running Tomcat 5.0.27 on Java 1.5 beta 2; I am using MySQL 4.1.2 Inside /common/lib/ I have mysql-connector.jar which is 3.0.14 â production version. Inside my server.xml I have (relevant stuff): <Host appBase="/home/resk/web" name="resk" autoDeploy="true" unpackWARs="true" liveDeploy="true"> </Host> Inside my /conf/Catalina/resk I have resk.xml: <?xml version='1.0' encoding='utf-8'?> <Context debug="5" displayName="RESK" docBase="ROOT" // BY THE WAY I also tried /home/resk/web/ROOT path="/" reloadable="false"> <Environment name="data.source.name" type="java.lang.String" value="java:comp/env/jdbc/RESK"/> // BTW I tried without this line <Resource auth="Container" name="jdbc/RESK" type="javax.sql.DataSource"/> <ResourceParams name="jdbc/RESK"> <parameter> <name>url</name> <value>jdbc:mysql://127.0.0.1:3306/resk?autoReconnect=true</value> </parameter> <parameter> <name>maxIdle</name> <value>2</value> </parameter> <parameter> <name>maxActive</name> <value>10</value> </parameter> <parameter> <name>driverClassName</name> <value>com.mysql.jdbc.Driver</value> </parameter> <parameter> <name>maxWait</name> <value>10000</value> </parameter> <parameter> <name>removeAbandoned</name> <value>true</value> </parameter> <parameter> <name>username</name> <value>resk</value> </parameter> <parameter> <name>factory</name> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value> </parameter> <parameter> <name>removeAbandonedTimeout</name> <value>60</value> </parameter> <parameter> <name>password</name> <value>RESK</value> </parameter> </ResourceParams> </Context> Inside my /home/resk/web/ROOT/WEB-INF/ I have web.xml (relevant stuff): <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" > <resource-ref> <description>DB Connection</description> <res-ref-name>jdbc/RESK</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> <!-- Used for startup primarly. Kepping things in one place. --> <env-entry> <env-entry-name>data.source.name</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value>java:comp/env/jdbc/RESK</env-entry-value> </env-entry> Now, hereâs how I load the data source (relevant part of the class): public class Manager { DataSource ds; static Manager instance; private Manager() { try { // This is all the web.xml properties InitialContext context = new InitialContext(); dbDataSource = (String)context.lookup("java:comp/env/data.source.name"); ds = (DataSource) new InitialContext().lookup(dbDataSource); } catch ( NamingException e ) { Logger.getLogger("problem").fatal("Unable to load database data source!",e); ds = null; // This will throw enough exceptions to notice the problem :) } } /** * @return instance of the Manager. */ public static Manager getInstance() { if (instance == null) instance = new Manager(); return instance; } /** * @return Connection from the pool. Make sure to close it when done. */ public synchronized Connection getConnection() throws SQLException { return ds.getConnection(); } â } Now, interesting thing to note. If I look at my catalina_log.2004-07-11.txt, I will find the following: 2004-07-11 20:47:47 NamingContextListener[/Catalina/resk/]: Resource parameters for jdbc/RESK = ResourceParams[name=jdbc/RESK, parameters={url=jdbc:mysql://127.0.0.1:3306/resk?autoReconnect=true, maxIdle=2, maxActive=10, driverClassName=com.mysql.jdbc.Driver, maxWait=10000, removeAbandoned=true, username=resk, factory=org.apache.commons.dbcp.BasicDataSourceFactory, removeAbandonedTimeout=60, password=RESK}] 2004-07-11 20:47:47 NamingContextListener[/Catalina/resk/]: Adding resource ref jdbc/RESK 2004-07-11 20:47:47 NamingContextListener[/Catalina/resk/]: ResourceRef[className=javax.sql.DataSource,factoryClassLocation=null,factoryClassName=org.apache.naming.factory.ResourceFactory,{type=scope,content=Shareable},{type=auth,content=Container},{type=url,content=jdbc:mysql://127.0.0.1:3306/resk?autoReconnect=true},{type=maxIdle,content=2},{type=maxActive,content=10},{type=driverClassName,content=com.mysql.jdbc.Driver},{type=maxWait,content=10000},{type=removeAbandoned,content=true},{type=username,content=resk},{type=factory,content=org.apache.commons.dbcp.BasicDataSourceFactory},{type=removeAbandonedTimeout,content=60},{type=password,content=RESK}] 2004-07-11 20:47:47 NamingContextListener[/Catalina/resk/]: Adding environment entry data.source.name 2004-07-11 20:47:47 NamingContextListener[/Catalina/resk/]: Resource parameters for UserTransaction = null Looking through this stuff itâs obvious that my resource IS found, and that it IS loaded. Yet, somehow, My application does not see itâ Anybody knows why? Any help will be greatly appreciatedâ _____ Best Regards, Ivan V. Jouikov (206) 228-6670 HYPERLINK "http://www.ablogic.net/" --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.716 / Virus Database: 472 - Release Date: 05.07.2004 --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.716 / Virus Database: 472 - Release Date: 05.07.2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.716 / Virus Database: 472 - Release Date: 05.07.2004