tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <>
Subject Re: Error in configuring JDBC Datasource
Date Sun, 14 Nov 2010 15:44:56 GMT
2010/11/14 Jayaprakash Ramsaran <>:
> Sever: Springsource tc server-developer-2.1.0/ tomcat-6.0.29.B
> O/S: Windows Vista
> I am using Springsource Tool Suite 2.5.1 and tc server 2.1. I am
> trying to configure a data source to PostgresSql. I followed the steps
> outlined in

The URL above is unreadable (because of "...")

> 1. I tried to add data source resource in
> $CATALINA_BASE/conf/Catalina/localhost/<myappcontextfilename>.xml file
> similar to the one below. Unfortunately, Springtool suite keeps
> overwriting this file and the <Resource name...> definition is lost.
> Springsuite overwrites it with <Context docBase.... source=..../>
> without resource name definition.
>            <Context
> docBase="C:\springsource\tc-server-developer-2.0.4.RELEASE\spring-insight-instance\wtpwebapps\myapp"

Springsuite ?  I do not know what it is, but similar behaviour is
known in Eclipse IDE: unless you set "Publish contexts as xml files"
property on the server configuration page (don't remember its exact
name, but you will see) it adds <Context> element into server.xml
(which is generally not recommended).

The "wtpwebapps" in the path above suggests that it is Eclipse WTP
doing it.  Note also, that it mentions "2.0.4", while you are saying
it was "2.1".

There was an Eclipse Tomcat FAQ somewhere.

> 2. Then I attempted to define it as a global resource though the
> Apache link warns that it some time does not work. The definition is
> given below.
>    <GlobalNamingResources>
>        <Resource auth="Container"
> 3. Then I add the resource reference in web.xml as below.
>  <resource-ref>
>    <description>postgreSQL Datasource example</description>
>    <res-ref-name>jdbc/postgres</res-ref-name>
>    <res-type>javax.sql.DataSource</res-type>
>    <res-auth>Container</res-auth>
>  </resource-ref>

2. + 3. is not enough. You will need to add <ResourceLink> element
into your context.xml.

(And that brings you back to the question of which context.xml is used).

Note, that when Tomcat is run from within Eclipse the context files
and server.xml can become stale. I use "Republish" from context menu
in the servers view. (There is also "Clean" etc.).

> 4. But when the spring tc server comes up, it gives the below error.
> Nov 13, 2010 10:42:09 PM org.apache.naming.NamingContext lookup
> WARNING: Unexpected exception resolving reference
> java.sql.SQLException
>        at (...)
> Caused by: java.lang.NullPointerException
>        at java.lang.Class.forName0(Native Method)
>        at java.lang.Class.forName(
>        at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(
>        ... 41 more

which probably means that it was a call to Class.forName(null).

Best regards,
Konstantin Kolinko

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

View raw message