tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: DB connection error -Tomcat 6 config
Date Thu, 18 Mar 2010 19:02:58 GMT
Hash: SHA1


On 3/18/2010 1:16 PM, Propes, Barry L wrote:
> <Resource name="jdbc/myoracle" 

> In web.xml, located in.../webapps/chngctrl/WEB-INF/web.xml 
> (for what it's worth, and I think it's immaterial, this at the top-)
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <web-app xmlns=""
>    xmlns:xsi=""
>    xsi:schemaLocation=""
>    version="2.5"> 
> <resource-ref>

The <resource-ref> element should be at the bottom of web.xml: check the
schema definition. I'm not sure this is causing your error, but you
ought to make web.xml conform to the schema.

>     <description>Change Ctrl App</description>
>     <res-ref-name>jdbc/myoracle</res-ref-name>
>     <res-ref-type>javax.sql.DataSource</res-ref-type>
>     <res-auth>Container</res-auth>

...actually, I checked" and I can't find an
allowed element <resource-ref> in the 2.5 schema (which certainly is
surprising to me). Try taking-out your <resource-ref> element entirely
and see what happens.

> Context initCtx = new InitialContext();
> Context envCtx = (Context) initCtx.lookup("java:comp/env");
> // Look up our data source
> DataSource ds = (DataSource) envCtx.lookup("jdbc/myoracle");

I have my JNDI path as "java:/comp/env/jdbc/[dbname]". IIRC, the leading
'/' is optional, so you should be good.

> // Allocate and use a connection from the pool
> Connection connection = ds.getConnection();
> All this has worked fine in 4.1.31 -- the two different versions of TC 6 (.0.18 and 0.24)
I've not had any luck with it.

Note that you updated your web.xml to use the new 2.5 Schema instead of
sticking with the 2.3 DTD that you were using: that changes some of the
rules by which Tomcat plays. You might consider using this header instead:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

- -chris
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla -


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

View raw message