title: NameNotFoundException mapping JNDI Datasource to Local name
body: <p>Im having trouble mapping a Weblogic (12c) defined JNDI Datasource to a local jndi name.</p>
  
  <p>I have a datasource in weblogic mysql datasource defined as "mysqltestds", and I want to map i within a web application to a local name "localds"</p>
  
  <p>My web.xml properties are</p>
  
  <pre><code>&lt;resource-ref&gt;
     &lt;res-ref-name&gt;localds&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;/resource-ref&gt;
  </code></pre>
  
  <p>with the weblogic.xml</p>
  
  <pre><code>&lt;weblogic-web-app&gt;
     &lt;resource-description&gt;
        &lt;res-ref-name&gt;localds&lt;/res-ref-name&gt;
        &lt;jndi-name&gt;mysqltestds&lt;/jndi-name&gt;lls
     &lt;/resource-description&gt;
  &lt;/weblogic-web-app&gt;
  </code></pre>
  
  <p>When I get the datasource using the global name "mysqltestds" it works correctly.</p>
  
  <pre><code>Context initialContext = new InitialContext();
  Object resource = initialContext.lookup("mysqltestds");
  dataSource = (DataSource) resource; 
  </code></pre>
  
  <p>However, when I try "localds" it fails with the error:</p>
  
  <pre><code>Context initialContext = new InitialContext();
  Object resource = initialContext.lookup("localds");
  dataSource = (DataSource) resource; 
  </code></pre>
  
  <blockquote>
    <p>javax.naming.NameNotFoundException: Unable to resolve 'localds'. Resolved ''; remaining name 'localds'</p>
  </blockquote>
  
  <p>Can anyone help. I followed the directions in this stackOverflow question <a href="https://stackoverflow.com/questions/47676/tomcat-vs-weblogic-jndi-lookup">Tomcat vs Weblogic JNDI Lookup</a> , but I haven't had any success.</p>