You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "KARR, DAVID" <dk...@att.com> on 2017/03/14 20:20:13 UTC

When do I actually need to add JNDI references to web.xml?

I have a small CXF/REST/Spring/JDBC app that I've run on TomEE and Tomcat.  I define datasources and environment entries and retrieve those from the application code using JNDI interfaces.  This all works fine.

What confuses me is that whenever I read in various unrelated docs about setting and using JNDI entries, even in applications running in Tomcat, it says that I also have to put resource reference elements into my application's "web.xml" file.  I don't think I've EVER added those elements to a web.xml file, and I've defined and used JNDI resources in many applications, including the current one.

As I'm getting these resources through Spring, does that somehow make it unnecessary to add those elements?

When are they actually required?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: When do I actually need to add JNDI references to web.xml?

Posted by "KARR, DAVID" <dk...@att.com>.
> -----Original Message-----
> From: KARR, DAVID
> Sent: Tuesday, March 14, 2017 1:20 PM
> To: Tomcat Users List <us...@tomcat.apache.org>
> Subject: When do I actually need to add JNDI references to web.xml?
> 
> I have a small CXF/REST/Spring/JDBC app that I've run on TomEE and
> Tomcat.  I define datasources and environment entries and retrieve those
> from the application code using JNDI interfaces.  This all works fine.
> 
> What confuses me is that whenever I read in various unrelated docs about
> setting and using JNDI entries, even in applications running in Tomcat,
> it says that I also have to put resource reference elements into my
> application's "web.xml" file.  I don't think I've EVER added those
> elements to a web.xml file, and I've defined and used JNDI resources in
> many applications, including the current one.
> 
> As I'm getting these resources through Spring, does that somehow make it
> unnecessary to add those elements?
> 
> When are they actually required?

I suppose I can self-answer this somewhat, but I'd still appreciate another POV.

From what I understand, I can see two reasons why the resource reference might be required:
* If the application code needs to reference it with a different name than is in JNDI
* If an application framework needs to inspect the configuration model of an application, to see those declared references, to perform background infrastructure actions associated with those references

The first is pretty obvious, but I just read about a large framework that looks for these declared references to perform automated actions.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org