In Tomcat, it looks like I must specify any JNDI resources in both the context.xml
and my web.xml
. Is this correct? Is there any way around this? I would think that one configuration in the context.xml
would be sufficient. Here is the related documentation from the Tomcat User Guide.
Note that the resource name (here, bean/MyBeanFactory must match the value specified in the web application deployment descriptor.
Glassfish does not require configuration in this manner. In Glassfish, you configure the JNDI resources (like a JDBC connection pool) on the server, and the application code gains a reference to the resource though the JNDI lookup. There is no need to an extra entry in the web.xml file.
What I'm concerned abut is this: if Glassfish reject this duplicate JNDI configuration, but Tomcat requires it, then I suddenly need to support two web.xml files, depending on the environment the application will be deployed to. It simply seems more complicated and cumbersome than it needs to be.