tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject DataSource Problems - Unresolved Issues
Date Sun, 04 Aug 2002 15:11:47 GMT
I've been having extreme difficulty getting the DataSource to work with
Tomcat 4.0.4.  I did finally manage to get it working though.  I have two
goals for this email.  1) To tell people who are struggling how I got it to
work and 2) To ask the Tomcat experts if there are problems in the latest
version that require the "hacks" that I used or am I just doing things

First, I started with Tomcat 4.0.3 (and Oracle 8i) and followed the very
limited available documentation on the subject.  I was able to get look up
my data source with JNDI but that was it.  I couldn't get an actual
connection.  Then I tried Tomcat 4.0.4 and got a new error message in the
Tomcat console about how TyrexDataSourceFactory couldn't find
org.hsql.jdbcDriver class.  That was odd b/c I was trying to use the Oracle
driver!  Btw, I did copy the oracle driver to the common/lib dir so it
should've found it.  Also, I noticed in the 4.0.4 release notes it said that
there were error msgs for Tyrex added so that's probably why I was getting
those all of a sudden.

I noticed that the "examples" Context had some mapping related to this so I
commented that out but that didn't help.  Then I decided I would look at the
source for the TyrexDataSourceFactory since I suspected that it was using
the default driver b/c it didn't know about mine (or couldn't find it).  I
changed the defaults to be the relevant stuff for my Oracle db and
recompiled that class only into a special jar which I made sure was in the
classpath before starting Tomcat.  This worked!  Actually I don't know for
sure that it worked b/c I did this at home and the db is at work but it
stopped complaining about the driver and just said it couldn't connect to
the db (which I expected).

To recap, I was using Tomcat 4.0.4 and had the Oracle driver in the
common/lib directory.  I also mapped the data source in the deployment
descriptor of my web app.  Here are the relevant portions of the server.xml
and web.xml files respectively:

<!-- Oracle Connection Pooling Stuff -->

<Context path="/ect" docBase="ect" debug="0" reloadable="false"
    <Resource name="jdbc/ClassroomTest_DS" auth="Container"
    <ResourceParams name="jdbc/ClassroomTest_DS">



<!-- deployment descriptor code -->


// java client code (in JSP)

InitialContext jndiContext = null;
Context context = null;
DataSource dataSource = null;

    jndiContext = new InitialContext();
    context = (Context)jndiContext.lookup("java:comp/env");

    dataSource = (DataSource)context.lookup("jdbc/ClassroomTest_DS");
    System.out.println("datasource found.");

catch (Exception e)
    System.out.println("*** Lookup Failed: " + e);

Hopefully, this can help somebody out there get this working.  Also,
hopefully someone can explain to me what I'm doing wrong or whether there is
an outstanding issue in the Tomcat source that is being worked on.


- sean

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message