You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Bryan Austad <ba...@xtendsoft.com> on 2002/02/20 20:35:07 UTC
javax.naming.NoInitialContextException:
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: <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>