Hi,
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 [mailto:[EMAIL PROTECTED]
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"
type="javax.sql.DataSource"/>
<ResourceParams name="ReportsDB">
<parameter><name>maxActive</name><value>100</value></parameter>
<parameter><name>maxIdle</name><value>10</value></parameter>
<parameter><name>maxWait</name><value>10000</value></parameter>
<parameter><name>user</name><value>user</value></parameter>
<parameter><name>password</name><value>password</value></parameter>
<parameter><name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value></parameter>
<parameter><name>driverName</name>
<value>jdbc:oracle:thin:@myhost.edu:1521:LIBR</value></parameter>
</ResourceParams>
When I deploy the servlet on my development server (Tomcat 4.06) it
runs
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
naming
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]