title: How to lookup a (JDBC) JNDI resource?
body: <p>We have a <strong>personal java library</strong> which is deployed on a tomcat server (v5.5 &amp; v6).
  This library is shared with many web applications, so it was deployed on shared/lib in tomcat directory.</p>
  
  <p>Exceptionaly, i have to create a new class into this library which lookup a jdbc datasource via JNDI.</p>
  
  <p>For that, here my code :</p>
  
  <pre><code>Context initCtx = new InitialContext();
  Context envCtx = (Context) initCtx.lookup("java:comp/env");
  DataSource dataSource = (DataSource) envCtx.lookup("jdbc/corp.xx.xx.xxxxDS");
  </code></pre>
  
  <p>All context are instantiated without problem. But when it lookup the jdbc datasource, i have an exception : Name jdbc not Found in Context</p>
  
  <p>We are not in a webapp, is it a problem ?
  Is it possible to declare a context.xml with a ResourceLink ? how ?</p>
  
  <p>nb: the jndi is setted in server.xml (a resource in GlobalNamingResources)</p>