title: <resource-ref> usage in Web.xml with Tomcat 5.5 and Spring
body: <p>I am doing a Jndi look up using <code>&lt;jee:jndi-lookup&gt;</code> . Everything works fine but as per the Jndi resource <a href="http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html#JDBC_Data_Sources" rel="nofollow noreferrer">reference</a> in Tomcat site , we need the <code>&lt;resource-ref&gt;</code> in Web.xml . I am not able to understand why we need this. Everything works fine if I have a context.xml under the conf folder without the web.xml definitions .</p>
  
  <p>My question is whether  <code>&lt;resource-ref&gt;</code> is required only when we lookup Jndi through plain Java code(<code>InitialContext().lookup("...")</code>) and not via Spring  .I am not sure if we need this here also.</p>
  
  <p>I saw a discussion on this at <a href="https://stackoverflow.com/questions/2887967/what-is-resource-ref-in-web-xml-used-for">What is resource-ref in web.xml used for?</a> but the configuration below</p>
  
  <pre><code>&lt;resource-ref&gt;
    &lt;res-ref-name&gt;jdbc/primaryDB&lt;/res-ref-name&gt;
    &lt;jndi-name&gt;jdbc/PrimaryDBInTheContainer&lt;/jndi-name&gt;
  &lt;/resource-ref&gt;
  </code></pre>
  
  <p>does not seem to work as stated when I use it in the application's web.xml(under WEB-INF) . I think it's specific to JBoss web.xml. Please help me understand .</p>