tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pid...@pidster.com>
Subject Re: Context.INITIAL_CONTEXT_FACTORY
Date Thu, 01 Feb 2007 14:30:52 GMT
Fran Varin wrote:
> Hi, 
> 
> We are in the process of trying to use Tomcat 5.5.20 to access an existing
> DB2 Database. Up until this point the application has been running under
> WebSphere (We are trying to utilize Tomcat for testing purposes). In
> WebSphere we can supply an IBM JNDI Factory Class named
> "com.ibm.websphere.naming.WsnInitialContextFactory" as the
> "Context.INITIAL_CONTEXT_FACTORY". We can then find our driver and all is
> well. 
> 
> Clearly, in Tomcat the above mentioned class does not exist. I've been all
> over the place trying to find an equivalent class that is part of Tomcat. It
> boils down to my attempt at using
> "org.apache.naming.java.javaURLContextFactory". However, when I do I receive
> "javax.naming.NameNotFoundException: Name jdbc is not bound in this
> Context:". 
> 
> I need to resolve this issue in order to move forward with using Tomcat but,
> cannot seem to find a good example that explains how to do this. I've seen
> the documents that loosely describe change server.xml and creating a
> context.xml for the application. But, this seems like the wrong path given
> the way that we have always proceeded with creating DB connections. So, it
> has really just added to my confusion. 
> 
> Any help would be greatly appreciated, 
> 
> Fran 
> 

InitialContext initialContext = new InitialContext();
Context rootContext = (Context) initialContext.lookup("java:comp/env");
DataSource ds = (DataSource) rootContext.lookup("jdbc/Database");

http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html


Assuming that you've configured a DataSource in server.xml.

p


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message