Re: DBCP+TOMCAT 3.2.4 - javax.naming.NoInitialContextException

2003-02-05 Thread ps
It appears that it needs more than an empty constructor in
InitialContext():

try{
   Context initCtx = new InitialContext();
   Context envCtx = (Context)initCtx.lookup(java:comp/env/);
   this.ds = (DataSource)envCtx.lookup(/jdbc/ngincaredb);
}
catch(NamingException e){
   logger.fatal(datasource error, e);
}

So, the solution maybe doing something like this:

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, );
Context initCtx = new InitialContext(env);

But the obvious question (and unknown for me) is what should be the
tomcat 3.2.4 default JNDI factory to put in
Context.INITIAL_CONTEXT_FACTORY attribute?? And why in tomcat 4.1.x it's
enough put a empty InitialContext()?? 

I don't find docs for tomcat 3.2.x about the resources/jndi...

thanks,
Pedro Salazar.

On Wed, 2003-02-05 at 11:48, ps wrote:
 Please, how should I interpret the exception message header below:
 
 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.factory.initial
 
 I'm using jdk1.4.1 (SUN) and tomcat 3.2.4.
 
 thanks,
 Pedro Salazar.
 

-- 
ps 
[EMAIL PROTECTED]
key id: 0E129E31D803BC61


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




javax.naming.NoInitialContextException:

2002-02-20 Thread Bryan Austad

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
parameternameuser/namevaluedavinci/value/parameter

parameternamepassword/namevaluedavinci/value/parameter
parameternamedriverClassName/name
valueoracle.jdbc.driver.OracleDriver/value/parameter
parameternamedriverName/name
valuejdbc: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:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]