tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bryan Austad" <baus...@xtendsoft.com>
Subject javax.naming.NoInitialContextException:
Date Wed, 20 Feb 2002 19:35:07 GMT
I am getting the error:
	 javax.naming.NoInitialContextException: Need to specify class name in
environment or system property, or as an applet parameter, or in an
application resource file:  java.naming.

I am using Tomcat 4.0.2, and trying to use its database pooling.  The first
few calls work, but then I eventually get this error.  I have a separate
class that manages retrieving and releasing the connections to the pool.
Here is the method that is used to retrieve the connection.

     public static Connection getConnection (String dsName) throws
javax.naming.NamingException,Exception{
       Context initCtx = new InitialContext();
       Context envCtx = (Context) initCtx.lookup("java:comp/env");
       DataSource ds = (DataSource)
       envCtx.lookup(dsName);
       Connection conn = ds.getConnection();
       return conn;
   }

There error gets thrown on the line:
     Context envCtx = (Context) initCtx.lookup("java:comp/env");

Once again, it works when you first try to get a connection.  Here are the
settings I have in server.xml for the database.

           <!-- Apache SOAP Context -->
	<Context path="/soap" docBase="soap"
         reloadable="true">
        	<Resource name="jdbc/DaVinci" auth="SERVLET"
                 type="javax.sql.DataSource"/>
          	<ResourceParams name="jdbc/DaVinci">
            	<parameter><name>user</name><value>davinci</value></parameter>

<parameter><name>password</name><value>davinci</value></parameter>
            	<parameter><name>driverClassName</name>
              	<value>oracle.jdbc.driver.OracleDriver</value></parameter>
            	<parameter><name>driverName</name>
              	<value>jdbc:oracle:thin:@[the_host]:xprod</value></parameter>
          </ResourceParams>
        </Context>

Here are the web.xml settings I have...
  <resource-ref>
    <description>
    Resource reference to a factory for java.sql.Connection
    instances that may be used for talking to a particular
    database that is configured in the server.xml file.
    </description>
    <res-ref-name>
      jdbc/DaVinci
    </res-ref-name>
    <res-type>
      javax.sql.DataSource
    </res-type>
    <res-auth>
      Container
    </res-auth>
  </resource-ref>

Can anyone help me?
Thanks
Bryan


--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message