Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-2896

Cannot obtain DataSource using JNDI Name lookup

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Blocker Blocker
    • 8.0.0.Final
    • 8.0.0.Final
    • Naming
    • None

      Hi,
      I'm having a problem to obtain DataSource using JNDI Name lookup.
      Please see my code and error below:

      Connection connection = null;
      DataSource dataSource = null;
      try

      { final Context initContext = new InitialContext(); dataSource = (DataSource) initContext.lookup("java:/MyDataSource"); connection = dataSource.getConnection(); }

      catch (Exception e)

      { LOGGER.error(e); }

      Caused by: javax.naming.NamingException: JBAS011832: Could not dereference object [Root exception is java.lang.NullPointerException]
      at org.jboss.as.naming.NamingContext.getObjectInstance(NamingContext.java:526)
      at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:236)
      at org.jboss.as.naming.InitialContext$DefaultInitialContext.lookup(InitialContext.java:233)
      at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:188)
      at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:184)
      at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0_45]
      at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0_45]
      ... 10 more
      Caused by: java.lang.NullPointerException
      at org.jboss.as.naming.NamingContext.getObjectInstance(NamingContext.java:522)
      ... 17 more

              dlloyd@redhat.com David Lloyd
              eagleigor Igor Shulika (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: