0 Replies Latest reply on Sep 22, 2008 8:42 PM by Joe Dean

    Local JNDI not working with embedded JBoss in Tomcat 5.5.9

    Joe Dean Newbie

      When 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:
      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 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)
       at com.onsitemanager.database.QueryResults.<init>(QueryResults.java:130)
       at com.onsitemanager.system.User.getUser(User.java:1055)]


      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!!!