Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Tomcat can't find my JDBC Resource !!!

Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'

Is the error I get.

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">


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="" type="java.lang.String" value="java:comp/env/jdbc/RESK"/> // BTW I tried without this line

<Resource auth="Container" name="jdbc/RESK"


<ResourceParams name="jdbc/RESK">











































Inside my /home/resk/web/ROOT/WEB-INF/ I have web.xml (relevant stuff):

<web-app version="2.4"



xsi:schemaLocation="" >


<description>DB Connection</description>





<!-- Used for startup primarly. Kepping things in one place. -->






Now, here�s how I load the data source (relevant part of the class):

public class Manager


DataSource ds;

static Manager instance;

private Manager()




// This is all the web.xml properties

InitialContext context = new InitialContext();

dbDataSource = (String)context.lookup("java:comp/env/");

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://, 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://},{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

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�
It's a tiny ad only because the water is so cold.
We need your help - Coderanch server fundraiser
    Bookmark Topic Watch Topic
  • New Topic