title: JNDI - JDBC resource lookup failes in WAS 7
body: <p>My code is unable to do lookup a JDBC resource using JNDI. I am getting the following exception:</p>
  
  <p>[Root exception is javax.naming.NameNotFoundException: Context: ppp-14415Node01Cell/nodes/ppp-14415Node01/servers/server1, <strong>name: jdbc/admincob: First component in name admincob not found</strong>. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]]</p>
  
  <p>I have followed these 2 solution on SO, but still its not working</p>
  
  <p><a href="https://stackoverflow.com/questions/4628915/websphere-6-1-to-7-how-to-update-ibm-web-bnd-xmi-to-ibm-web-bnd-xml">Websphere 6.1 to 7 how to update ibm-web-bnd.xmi to ibm-web-bnd.xml</a></p>
  
  <p><a href="https://stackoverflow.com/questions/7167212/how-do-i-connect-to-a-websphere-datasource-with-a-given-jndi-name">How do I connect to a Websphere Datasource with a given JNDI name?</a></p>
  
  <p>Here is my ibm-web-bnd.xml</p>
  
  <pre><code>    &lt;virtual-host name="default_host" /&gt;
  &lt;resource-ref name="jdbc/dbcob" binding-name="jdbc/admincob" /&gt;
  </code></pre>
  
  <p>and portion of web.xml</p>
  
  <pre><code>    &lt;resource-ref&gt;
      &lt;description&gt;
  Datasource connection to db&lt;/description&gt;
      &lt;res-ref-name&gt;jdbc/dbcob&lt;/res-ref-name&gt;
      &lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt;
      &lt;res-auth&gt;Container&lt;/res-auth&gt;
      &lt;res-sharing-scope&gt;Shareable&lt;/res-sharing-scope&gt;
  &lt;/resource-ref&gt;
  </code></pre>
  
  <p>Here is the screenshot of the binding:
  <img src="https://i.stack.imgur.com/XAbeS.png" alt="binding description"></p>
  
  <p>Lookup code:</p>
  
  <pre><code>       Context initialContext = new InitialContext();
  
          DataSource datasource = (DataSource) initialContext
                  .lookup("java:comp/env/jdbc/dbcob");
          if (datasource != null) {
              result = datasource.getConnection();
              System.out.println("Data connection retrieved");
              result.close();
          } else {
              System.err.println("Failed to lookup datasource.");
          }
  </code></pre>
  
  <p>I am not sure what am I missing. Please help.</p>
  
  <p><img src="https://i.stack.imgur.com/ZSmxv.png" alt="enter image description here">
  <img src="https://i.stack.imgur.com/NOxAG.png" alt="enter image description here"></p>