local JNDI not working in embedded JBoss on Tomcat 5.5.
joe Sep 23, 2008 7:24 PMWhen I try to do a lookup on my data source as follows:
`Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
return (DataSource) envCtx.lookup(type.getName());`
I get the following exception
<pre>
java.sql.SQLException: QueryResults: Unable to initialize naming context: Name java:comp is not boun
d in this Context
at com.onsitemanager.database.ThreadLocalConnection.getConnection(ThreadLocalConnection.java:130)
at com.onsitemanager.database.ThreadLocalConnection.getDatabaseConnection(ThreadLocalConnection.java:87)
at com.onsitemanager.database.QueryResults.allocateAndExecute(QueryResults.java:865)
at com.onsitemanager.database.QueryResults.execute(QueryResults.java:897)
</pre>
I updated the $TOMCAT_HOME/conf/server.xml as follows:
`<Server port="8005" shutdown="SHUTDOWN">
<!-- Comment these entries out to disable JMX MBeans support used for the
administration web application -->
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
<!-- Listener required for embedded JBoss -->
<Listener className="org.jboss.embedded.tomcat.EmbeddedJBossBootstrapListener"/>
...`
And added to the $TOMCAT_HOME/conf/context.xml:
`<!-- The contents of this file will be loaded for each web application -->
<Context>
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
<!-- Embedded JBoss -->
<Listener className="org.jboss.embedded.tomcat.WebinfScanner" />
</Context>`
Am I missing something with this configuration? I'm trying to lookup my datasource which is configured properly in a -ds.xml file in my war's WEB-INF/classes directory. What do I need to do to TOMCAT configuration to get it to initialize the java:comp in the JBoss naming context. Note: If I use apache naming context it works fine. Please Help!!!
`Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
return (DataSource) envCtx.lookup(type.getName());`
I get the following exception
<pre>
java.sql.SQLException: QueryResults: Unable to initialize naming context: Name java:comp is not boun
d in this Context
at com.onsitemanager.database.ThreadLocalConnection.getConnection(ThreadLocalConnection.java:130)
at com.onsitemanager.database.ThreadLocalConnection.getDatabaseConnection(ThreadLocalConnection.java:87)
at com.onsitemanager.database.QueryResults.allocateAndExecute(QueryResults.java:865)
at com.onsitemanager.database.QueryResults.execute(QueryResults.java:897)
</pre>
I updated the $TOMCAT_HOME/conf/server.xml as follows:
`<Server port="8005" shutdown="SHUTDOWN">
<!-- Comment these entries out to disable JMX MBeans support used for the
administration web application -->
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
<!-- Listener required for embedded JBoss -->
<Listener className="org.jboss.embedded.tomcat.EmbeddedJBossBootstrapListener"/>
...`
And added to the $TOMCAT_HOME/conf/context.xml:
`<!-- The contents of this file will be loaded for each web application -->
<Context>
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
<!-- Embedded JBoss -->
<Listener className="org.jboss.embedded.tomcat.WebinfScanner" />
</Context>`
Am I missing something with this configuration? I'm trying to lookup my datasource which is configured properly in a -ds.xml file in my war's WEB-INF/classes directory. What do I need to do to TOMCAT configuration to get it to initialize the java:comp in the JBoss naming context. Note: If I use apache naming context it works fine. Please Help!!!