tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ravi Rangaswamy <>
Subject Help With Tomcat Database Connection Configuration
Date Thu, 16 Jan 2003 20:38:15 GMT


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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message