tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ps <pedro-b-sala...@ptinovacao.pt>
Subject TC 3.2.x : How to get DataSource (Resource) defined on server.xml?
Date Wed, 05 Feb 2003 16:06:54 GMT
Greetings,

could anyone tell me if it's *POSSIBLE* in *TOMCAT 3.2.4* to define a
<resource> of a datasource in server.xml for DBCP, a <resource-ref> in
web.xml, and retrieve it on init() of a servlet using JNDI??

I'm trying to do it as I do with TOMCAT 4.1.x, but I'm getting this
exception related to JNDI:

"
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
        at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)
        at
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
        at
javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)
        at javax.naming.InitialContext.lookup(InitialContext.java:347)
...
"

I'm doing this:

Context initCtx = new InitialContext();
this.ds = (DataSource)initCtx.lookup("java:comp/env/jdbc/ngincaredb");

but probably I should initialize the context like this (not necessary on
TOMCAT 4.1.x):

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

But, I have no clue what should I put in "??????" for use in tomcat
3.2.4...

please, can anyone give me a hint or if it's possible or not?

Or should I have to initialize a DBCP on my code using some properties?

thanks,
Pedro Salazar.

-- 
<ps> 
pedro-b-salazar@ptinovacao.pt
key id: 0E129E31D803BC61


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message