title: Null pointer exception when attempting to use JNDI for JDBC
body: <p>In Glassfish admin, I setup a JDBC connection pool that I can ping ok. Also in Glassfish admin, I have setup a JNDI JDBC resource called jdbc/myDb</p>
  
  <p>However I'm unable to connect to it from Java.  I have tried both injection style:</p>
  
  <pre><code>@Resource (mappedName="jdbc/myDB")
  private DataSource datasource;
  </code></pre>
  
  <p>I have also tried Context style :</p>
  
  <pre><code>Context ctx = new InitialContext();
  DataSource datasource = (DataSource)ctx.lookup("jdbc/myDB")
  </code></pre>
  
  <p>All I get is java.lang.NullPointerException.</p>
  
  <p>I have also tried various naming styles such as java:jdbc/myDB  or java:comp/env/jdbc/myDb</p>
  
  <p>This is using the latest Glassfish (4.1), the latest Postgres Driver (9.3-1102 JDBC 41) against Postgres 9.4, and the latest Java (1.8.0_31-b13).</p>