When I try to do the following search in my code:
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
return (DataSource) envCtx.lookup("jdbc/mydb");
I get the following exception:
java.sql.SQLException: QueryResults: Unable to initialize naming context:
Name java:comp is not bound in this Context at
com.onsitemanager.database.ThreadLocalConnection.getConnection
(ThreadLocalConnection.java:130) at
...
I installed the built-in JBoss according to the instructions of the JBoss wiki . And I configured Tomcat using the "Scan each WAR by default" deployment, as indicated on the wiki page .
Quote configuration page:
Jndi
JBoss embedded components, such as pooling, EJB, JPA, and transactions, make extensive use of JNDI to publish services. Built-in JBoss overrides the Tomcat JNDI implementation by splitting itself on top of the Tomcat JNDI instance. There are several reasons for this:
- To avoid declaring each of these services in server.xml
- java: comp - EJBs.
- Tomcat JNDI , JBoss
- EJB , .
- , JBoss, Tomcat JNDI, java: comp/env?
FYI - My environment Tomcat 5.5.9, Seam 2.0.2sp, Embedded JBoss (Beta 3),
. -ds.xml , .
: Jboss .