How to Setup Global JNDI Mapping
for Oracle JDBC Connection Pooling
with Tomcat

by Gregg Lagnese, MicroDeveloper, Inc.
May 16, 2005 v1.3
 
Steps <- Previous Introduction Next -> Dependent Connections
 

Troubleshooting

 
8) Check the database first
Verify database connectivity
a) TNSPing the database
b) Connect using the username and password in step 1
c) Verify the server, sid, and port
 
9) Error messages

Driver errors usually look like (Cannot create JDBC driver of class '' for connect URL 'null'):
Place the ojdbc14.jar file in the <CATALINA_HOME>\common\lib directory
Do NOT place the JAR in your <CONTEXT>/WEB-INF/lib directory (this can cause problems)
If used with an IDE that auto-deploys, exclude the JAR from the deployment

Javax Driver errors looking like "java.sql.SQLException: No suitable driver"
Usually means the JNDI lookup could not use the default javax implementation or Oracle driver (or both). Most people will tell you to use this construct:

<Resource name="jdbc/<alias>"
          auth="Container" 
          type="javax.sql.DataSource"
          driverClassName="oracle.jdbc.driver.OracleDriver"
          ...

But I never found that to work reliably. This works every time (see step 1); note the inclusion of the factory:

<Resource name="jdbc/<alias>"
          auth="Container" 
          type="oracle.jdbc.pool.OracleDataSource"
          driverClassName="oracle.jdbc.driver.OracleDriver"
factory="oracle.jdbc.pool.OracleDataSourceFactory"
...

Ensure that the resource link (step 2) is in either:
the <CONTEXT>/META-INF/context.xml file (for context configurations)
- or -
the <CATALINA_HOME>/conf/context.xml (for global configurations)

Error messages that 'jdbc' is an unknown context:
Verify that step (3 for 5.0) is complete and accurate.
Verify that you have all the correct JARs in place. Specifically these:

naming-factory.jar
naming-factory-dbcp.jar
naming-resources.jar

IO Error Messages 'Io exception: The Network Adapter could not establish the connection'
This almost always means that the URL is improperly formed. For the Oracle thin driver it's jdbc:oracle:thin:@<host>:<port>:<sid>
Pay extra attention to the colon ':' after 'thin' and the '@' symbol. These tend to be left out often (for me anyway).

 

 
Steps <- Previous Introduction Next -> Dependent Connections