tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <>
Subject RE: Binding DataSources to Contexts in Tomcat 4.06/4.1
Date Thu, 19 Aug 2004 18:08:09 GMT

Where in server.xml is your Resource declaration?  Is there a matching
resource-ref in your web.xml?  (It's required).  You also probably want
a factory parameter, as mentioned in the JNDI DataSources how-to.

Yoav Shapira
Millennium Research Informatics

>-----Original Message-----
>From: Jeffrey Barnett []
>Sent: Thursday, August 19, 2004 2:04 PM
>To: Tomcat Users List
>Subject: Binding DataSources to Contexts in Tomcat 4.06/4.1
>I have a servlet that contains the following code in its init() method:
>    public void init(ServletConfig config) throws ServletException {
>        super.init(config);
>        try {
>        Context initCtx = new InitialContext();
>        Context envCtx = (Context) initCtx.lookup("java:comp/env");
>        System.out.println("Context loaded: " );
>        ds = (DataSource) envCtx.lookup("ReportsDB");
>        System.out.println("DataSource found: " + ds.toString());
>        con = ds.getConnection();
>        con1 = ds.getConnection();
>        } catch(Exception e) {
>            System.err.println("Init Error " + e.getMessage());
>        }
>        System.out.println("Init Complete");
>    }
>the server.xml file contains:
><Resource name="ReportsDB" auth="Container"
>            <ResourceParams name="ReportsDB">
>             <parameter><name>driverClassName</name>
>             <value>oracle.jdbc.driver.OracleDriver</value></parameter>
>             <parameter><name>driverName</name>
>          </ResourceParams>
>When I deploy the servlet on my development server (Tomcat 4.06) it
>without error and reports "Init Complete" in the localhost log.
>The same code and xml deployed on a test server (tomcat 4.1.12) a
>exception is thrown and the catch block reports "Init Error Name
>ReportsDB is not bound in this Context".
>Is there a difference between the two releases that would explain this,
>or are other settings involved in "binding" that I should be examining?
>All suggestions gratefully accepted :-)
>To unsubscribe, e-mail:
>For additional commands, e-mail:

This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender.  Thank you.

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

View raw message