title: JNDI @Resource not found in Wildfly 10
body: <p>I'm trying to access to JNDI Oracle datasource through @Resource annotation in RestEasy webservice on Wildfly 10, but null is returned. It works with InitialContext.lookup method. This my java code:</p>
  
  <pre><code>@Path("/rest")
  public class ServiceTest {
      @Resource(name = "jdbc/OracleDS") DataSource source1;
      @Resource(name = "java:/jdbc/OracleDS") DataSource source2;
      @Resource(lookup = "java:/jdbc/OracleDS") DataSource source3;
  
      @GET
      @Path("/test")
      @Produces(MediaType.TEXT_PLAIN)
      public String testJNDI () {
          try {
              javax.naming.Context initCtx = new InitialContext();
              DataSource source4 = (DataSource)initCtx.lookup("java:/jdbc/OracleDS");
              initCtx.close();
              return "" + source1 + " / " + source2 + " / " + source3 + " / " + source4;
          } catch (Exception error) {
              e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>This is my standalone.xml datasource definition:</p>
  
  <pre><code>&lt;datasource jta="true" jndi-name="java:/jdbc/OracleDS" pool-name="OracleDS" enabled="true" use-ccm="true" statistics-enabled="true"&gt;
     &lt;connection-url&gt;
         jdbc:oracle:thin:@192.168.10.20:1521:log
     &lt;/connection-url&gt;
     &lt;driver-class&gt;oracle.jdbc.driver.OracleDriver&lt;/driver-class&gt;
     &lt;driver&gt;oracle&lt;/driver&gt;
     &lt;pool&gt;
         &lt;initial-pool-size&gt;1&lt;/initial-pool-size&gt;
         &lt;max-pool-size&gt;10&lt;/max-pool-size&gt;
     &lt;/pool&gt;
     &lt;security&gt;
         &lt;user-name&gt;user&lt;/user-name&gt;
         &lt;password&gt;passw&lt;/password&gt;
     &lt;/security&gt;
     &lt;validation&gt;
         &lt;valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/&gt;
         &lt;background-validation&gt;true&lt;/background-validation&gt;
         &lt;stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker"/&gt;
         &lt;exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"/&gt;
     &lt;/validation&gt;
     &lt;timeout&gt;
          &lt;blocking-timeout-millis&gt;30000&lt;/blocking-timeout-millis&gt;
          &lt;idle-timeout-minutes&gt;15&lt;/idle-timeout-minutes&gt;
          &lt;query-timeout&gt;300&lt;/query-timeout&gt;
     &lt;/timeout&gt;
     &lt;statement&gt;
         &lt;track-statements&gt;nowarn&lt;/track-statements&gt;
     &lt;/statement&gt;
  &lt;/datasource&gt;
  </code></pre>
  
  <p>And this is my module.xml code:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;module xmlns="urn:jboss:module:1.1" name="com.oracle"&gt;
      &lt;resources&gt;
          &lt;resource-root path="ojdbc6.jar"/&gt;
      &lt;/resources&gt;
      &lt;dependencies&gt;
          &lt;module name="javax.api"/&gt;
          &lt;module name="javax.transaction.api"/&gt;
      &lt;/dependencies&gt;
  &lt;/module&gt;
  </code></pre>
  
  <p>The service output is this:</p>
  
  <pre><code>null / null / null / org.jboss.as.connector.subsystems.datasources.WildFlyDataSource@4b1881
  </code></pre>
  
  <p>Why source4 founds the resource and others not? I expected that at least source3 would be like source4. Is something wrong in the @Resource definition?</p>
  
  <p>Thanks</p>