title: Setting up a datasource with WebSphere Liberty Profile 8.5
body: <p>My web app is getting a data source from JNDI with:</p>
  
  <pre><code>javax.naming.InitialContext ctx = new javax.naming.InitialContext();
  javax.sql.DataSource ds = (javax.sql.DataSource) 
      ctx.lookup("java:comp/env/jdbc/db");
  </code></pre>
  
  <p>In the app's <code>WEB-INF/web.xml</code>, I have:</p>
  
  <pre><code>&lt;resource-ref&gt;
      &lt;description&gt;DataSource&lt;/description&gt;
      &lt;res-ref-name&gt;jdbc/db&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>In the app's <code>WEB-INF/ibm-web-bnd.xml</code>, I have:</p>
  
  <pre><code>&lt;web-bnd
      xmlns="http://websphere.ibm.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-bnd_1_0.xsd"
      version="1.0"&gt;
      &lt;virtual-host name="default_host"/&gt;
      &lt;resource-ref name="jdbc/db" binding-name="jdbc/db"/&gt;
  &lt;/web-bnd&gt;
  </code></pre>
  
  <p>In WebSphere Liberty Profile's <code>server.xml</code>, I have (keeping on the relevant parts):</p>
  
  <pre><code>&lt;server description="new server"&gt;
  
      &lt;featureManager&gt;
          &lt;feature&gt;jsp-2.2&lt;/feature&gt;
          &lt;feature&gt;jdbc-4.0&lt;/feature&gt;
      &lt;/featureManager&gt;
  
      &lt;library id="oracle-lib"&gt;
          &lt;fileset dir="lib" includes="ojdbc5_g.jar"/&gt;
      &lt;/library&gt;
  
      &lt;dataSource jndiName="jdbc/db" jdbcDriverRef="oracle-driver" type="javax.sql.DataSource"&gt;
          &lt;jdbcDriver libraryRef="oracle-lib" id="oracle-driver"/&gt;
          &lt;connectionManager numConnectionsPerThreadLocal="10" id="ConnectionManager" minPoolSize="1"/&gt;
          &lt;properties user="user" password="password"
                      url="jdbc:oracle:thin:@//db-server:1521/db"/&gt;
      &lt;/dataSource&gt;
  
  &lt;/server&gt;
  </code></pre>
  
  <p>When the app attempts to get the datasource from JNDI, it fails with the following error:</p>
  
  <pre><code>CWNEN0030E: The @Resource factory encountered a problem getting
  the object instance jdbc/oracle binding object.  The exception message was: 
  failed to resolve jdbc/oracle to javax.sql.DataSource: 
  javax.naming.NameNotFoundException: 
  Intermediate context does not exist: jdbc/oracle
  </code></pre>
  
  <p>What I am missing here?</p>