Why do I get javax.naming.NameNotFoundException: jdbc not bound

Solution Verified - Updated -

Issue

SCENARIO 1

  • Deploying the following datasource configuration
    <datasources>      
       <local-tx-datasource>
          <jndi-name>jdbc/ContactsDS</jndi-name>
          <use-java-context>false</use-java-context>...</datasources>


  • Following exception is received-
Unexpected exception: javax.naming.NameNotFoundException: jdbc not bound
  • When the code does the following JNDI lookup
    DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/ContactsDS");    

SCENARIO 2

  • Deploying the following datasource configuration having <use-java-context>true</use-java-context>
   <datasources>      
       <local-tx-datasource>
          <jndi-name>jdbc/ContactsDS</jndi-name>
          <use-java-context>true</use-java-context>...</datasources>
  • Following exception is received-
Unexpected exception: javax.naming.NameNotFoundException: jdbc/ContactsDS not bound
  • When the code does the following JNDI lookup
    DataSource ds = (DataSource) ctx.lookup("jdbc/ContactsDS");    

Environment

  • JBoss Enterprise Application Platform (EAP)
    • 5.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content