You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Sean Dockery <se...@sbdconsultants.com> on 2003/01/28 19:35:49 UTC

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.)



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Consequence of not declaring a resource-ref?

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Tue, 28 Jan 2003, Sean Dockery wrote:

> Date: Tue, 28 Jan 2003 11:35:49 -0700
> From: Sean Dockery <se...@sbdconsultants.com>
> Reply-To: Tomcat Users List <to...@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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>