tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Eggers <>
Subject Re: How to configure JNDI resource
Date Mon, 13 Dec 2010 20:21:24 GMT

The resource-ref element in web.xml describes an external resource to your web 

The Resource element in either context.xml or server.xml describes to Tomcat how 
to create the resource being accessed by your web application.

The first (resource-ref) is part of the standard. The second (Resource) is 
Tomcat-specific. Different containers have different ways of describing 
resources to be created.

In order to use the resource, you'll need to tell your application about it 
(resource-ref in web.xml), and create it (Resource in context.xml or 
server.xml). Where you put the creation depends on your requirements.

. . . . just my two cents.


----- Original Message ----
From: Abid Hussain <>
Sent: Mon, December 13, 2010 8:18:44 AM
Subject: How to configure JNDI resource

Hi all,

I've a question about how to configure a datasource to be accessed via JNDI.

I have a datasource configured in server.xml (In

In the documentation
it says that that a resource/datasource can be declared in the context
element of a webapp like this:
<Context ...>
  <Resource name="jdbc/EmployeeDB" auth="Container" type="javax.sql.DataSource"
     description="Employees Database for HR Applications"/>

Also it is written that it is possible to declare a resource inside web.xml:
  <description>Employees Database for HR Applications</description>

My question is:
1) is it enough to declare the needed resource inside web.xml or
2) do I have to declare it also in the context element
for accessing it via JNDI?

And, if 2) is correct what is the use to declare a resouce in the
webapps web.xml when it has been already declared in the context
element of the webapp?



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


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

View raw message