tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roberts, Eric" <>
Subject RE: Help With Tomcat Database Connection Configuration
Date Fri, 17 Jan 2003 08:06:51 GMT

Your server.xml looks fine.

If you specify the resource in server.xml there is no need to put it in web.xml (in fact this
will more than likely cause problems).

You should reference the datasource in your app as follows:

    ctx = new InitialContext();
    Context envCtx = (Context) ctx.lookup("java:/comp/env/");
    DataSource ds = (DataSource) envCtx.lookup("/juddidb");

The class.forName() is used when you are not using DBCP but directly connecting.

Make sure that the Oracle is renamed to classes12.jar and in CATALINA_HOME/common/lib



-----Original Message-----
From: Ravi Rangaswamy []
Sent: Donnerstag, 16. Jänner 2003 21:38
To: TomcatUserList
Subject: Help With Tomcat Database Connection Configuration


I am running a UDDI registry (CATALINA_HOME/web-apps/juddi) from inside Tomcat. Now I want
to run the registry with Oracle. So, I created a JDBC datasource in Tomcat. To do this, I
followed these steps.

1. I added the segment in CATALINA_HOME/conf/server.xml inside the <context> element.

          <!-- Orcale JDBC datasource for jUDDI -->
          <Resource name="jdbc/juddidb" auth="Container"

          <ResourceParams name="jdbc/juddidb">
          <!-- End of Orcale JDBC datasource for jUDDI -->

2. I added this segment in CATALINA_HOME/web-apps/juddi/WEB_INF/web.xml inside the <web-app>

 <!-- Orcale JDBC datasource for jUDDI -->
  <description>Oracle Datasource</description>

When I start Tomcat and invoke a action on jUDDI, I get the exception

Cannot load JDBC driver class 'null'
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(
        at org.apache.commons.dbcp.BasicDataSource.createDataSource(
        at org.apache.commons.dbcp.BasicDataSource.getConnection(

So, to further debug, I added the segment from Step 2 to CATALINA_HOME/web-apps/examples/WEB_INF/web.xml
and created a jsp (shown at the end of the mail) to see if it was picking up the configuration
parameters. When this jsp is executed, I get the following displayed with the parameters as
specified in server.xml.

 DriverClassName: oracle.jdbc.driver.OracleDriver Url: jdbc:oracle:thin:@localhost:1521:orcl
Username: juddiUser Password: juddiUser MaxActive: 20 MaxWait: 5000 NumActive: 3 numIdle:

If I place the same jsp under CATALINA_HOME/web-apps/juddi/jsp/..... and run the jsp, I get
nulls for each param

 DriverClassName: null Url: null Username: null Password: null MaxActive: 8 MaxWait: -1 NumActive:
0 numIdle: 0

Can anyone tell me what I am doing wrong and why these two applications (examples and the
uddi registry) behave differently.



Test jsp

<%@ page language="java" import="java.sql.*,javax.naming.InitialContext,javax.naming.Context,javax.sql.DataSource,org.apache.commons.dbcp.BasicDataSource"

<body bgcolor="white">
<font color="red">

Connection conn = null;

try {

InitialContext initialContext = new InitialContext();
Context context = (Context)initialContext.lookup("java:comp/env");
DataSource ds = (DataSource)context.lookup("jdbc/juddidb");

out.print(" DriverClassName: " + ((BasicDataSource) ds).getDriverClassName());
out.print(" Url: " + ((BasicDataSource) ds).getUrl());
out.print(" Username: " + ((BasicDataSource) ds).getUsername());
out.print(" Password: " + ((BasicDataSource) ds).getPassword());
out.print(" MaxActive: " + ((BasicDataSource) ds).getMaxActive());
out.print(" MaxWait: " + ((BasicDataSource) ds).getMaxWait());
out.print(" NumActive: " + ((BasicDataSource) ds).getNumActive());
out.print(" numIdle: " + ((BasicDataSource) ds).getNumIdle());

} catch (Exception e) {


Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now

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

View raw message