tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ashvini K Saxena" <ashv...@fastmail.fm>
Subject Problem configuring JNDI DataSource for Oracle
Date Thu, 22 Jun 2006 18:10:42 GMT
I am trying to use a datasource to access an Oracle database (Tomcat
5.5.9 and Oracle 9i). I have configured a datasource in the context.xml
as follows:

<?xml version="1.0" encoding="UTF-8"?>
<Context
    reloadable="true">
  <Resource
    name="jdbc/reportdb"
    type="javax.sql.DataSource"
    url="jdbc:oracle:thin:rep@localhost:1521:rep"
    driverClassName="oracle.jdbc.OracleDriver"
    password="rep123"
    maxActive="4"
    maxWait="5000"
    maxIdle="2"
    username="rep"/>
  <WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>

In web.xml I am referring to the datasource as:

<resource-ref>
	<description>The Reports DataSource</description>
	<res-ref-name>jdbc/reportdb</res-ref-name>
	<res-type> javax.sql.DataSource</res-type>
	<res-auth>Container</res-auth>
	<res-sharing-scope>Unshareable</res-sharing-scope>
</resource-ref>

The code for creating connections is something like this:
try {
	Context ctx = (Context)(new InitialContext().lookup("java:comp/env"));
	DataSource ds = (DataSource)ctx.lookup("jdbc/reportdb");
	Connection con = ds.getConnection();
} catch (NamingException e) {
	e.printStackTrace();
} catch (SQLException e) {
	e.printStackTrace();
}

The Oracle JDBC driver, classes12.jar is in common/lib.

At runtime I get the following error:
java.lang.NullPointerException
	org.apache.tomcat.dbcp.dbcp.DelegatingConnection.close(DelegatingConnection.java:151)
	org.apache.tomcat.dbcp.dbcp.PoolableConnection.reallyClose(PoolableConnection.java:95)
	org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.destroyObject(PoolableConnectionFactory.java:301)
	org.apache.tomcat.dbcp.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:883)
	org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:851)
	org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
	gaim.ui.report.action.ShowReport.doPost(ShowReport.java:42)

Has anyone encountered a similar problem and know of a solution? Is
there anything I am missing in my configuration?

Thanks and Regards,

Ashvini K Saxena
-- 
  Ashvini K Saxena
  ashvini@fastmail.fm

-- 
http://www.fastmail.fm - IMAP accessible web-mail


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message