• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Tomcat 6 Datasource JNDI & web.xml resource-ref

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm confused on the need for the "resource-ref" in web.xml when deploying a context to Tomcat 6.

When I follow the directions in either the JNDI Resource HOW-TO or the JNDI Datasource HOW-TO they specify that you need to put a "resource-ref" entry in the web.xml file. If this element is removed the application is still able to find the JNDI lookup name and connect to the DataSource. It doesn't seem to matter if the DataSource is defined in any of the contexts or server.xml (with appropriate ResourceLink in context.xml).

I Googled around and found a tutorial on connecting Oracle to Tomcat which says for Tomcat 5.5.x, adding the resource-ref is not necessary (Step 3 on that page). In the servlet 2.5 maint rel 2 spec it states:

The resource-ref element contains a declaration of a web application’s reference to an external resource.



The Tomcat-Users mailing list had a response, but I'm still not quite getting it.

The server.xml sets up the actual resource (often in the <GlobalNamingResources> section), then allows the application to use it (by adding a <ResourceLink> section in the <Context> where you want to use it). The webapp signifies its desire to use that resource by including a complimentary <resource-ref> section in the deployment descriptor.



Why have a "resource-ref" in the web.xml? If it's signaling the web application's desire to use that resource, why does it still work when removed?
Does it let future deployers know that the app has an external JNDI dependency?

I've been beating my brain trying to find this answer. Thanks in advance!
 
And tomorrow is the circus! We can go to the circus! I love the circus! We can take this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic