tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: Consequence of not declaring a resource-ref?
Date Tue, 28 Jan 2003 20:52:09 GMT


On Tue, 28 Jan 2003, Sean Dockery wrote:

> Date: Tue, 28 Jan 2003 11:35:49 -0700
> From: Sean Dockery <sean@sbdconsultants.com>
> Reply-To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> To: tomcat-user@jakarta.apache.org
> Subject: Consequence of not declaring a resource-ref?
>
> I deployed a JDBC datasource in my web-app's context in server.xml, but I
> neglected to declare a resource-ref block in my WEB-INF/web.xml.  Tomcat
> successfully retrieved the datasource through JNDI anyway.  Out of
> curiousity, I tried removing the Resource declaration from server.xml and
> inserting a resource-ref block into WEB-INF/web.xml to see if Tomcat would
> complain about a resource-ref dependency, but Tomcat did not complain.
> There was nothing in the logs in either case.  Tomcat did fail to locate the
> JDBC datasource (as I expect it would) in the latter case.
>
> Does anyone know what the consequence of not declaring a resource-ref block
> in your WEB-INF/web.xml?  (Other than the obvious value to deployers to can
> see the logical names under which JDBC data sources should be deployed.)
>

Declaring resource references in web.xml is required by the J2EE specs,
but Tomcat doesn't currently enforce this restriction.

If you don't include the resource references, then:

* You're guaranteed to have problems if you port your
  app to a J2EE app server (although all the programmatic
  logic for accessing JNDI resources is portable, not having
  a resoruce ref declared is not portable).

* You're guaranteed to have problems if some future
  version of Tomcat decides to start enforcing this
  requirement.

My advice is to save yourself the potential problems and just include the
references like the docs tell you to.

Craig



--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message