title: JNDI resources in Tomcat
body: <p>In Tomcat, it looks like I must specify any JNDI resources in both the <code>context.xml</code> and my <code>web.xml</code>.  Is this correct?  Is there any way around this?  I would think that one configuration in the <code>context.xml</code> would be sufficient.  Here is the related documentation  <a href="https://sec1.woopra.com/docs/jndi-resources-howto.html#Generic_JavaBean_Resources" rel="nofollow">from the Tomcat User Guide</a>.</p>
  
  <blockquote>
    <p>Note that the resource name (here,
    bean/MyBeanFactory must match the
    value specified in the web application
    deployment descriptor. </p>
  </blockquote>
  
  <p>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.</p>
  
  <p>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.</p>