tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <Yoav.Shap...@mpi.com>
Subject RE: InitialContextFactory
Date Thu, 12 Aug 2004 15:33:48 GMT
Hi,
Tomcat has its own,
org.apache.catalina.naming.java.javaURLContextFactory.  See code at
http://cvs.apache.org/viewcvs.cgi/jakarta-tomcat-catalina/catalina/src/s
hare/org/apache/naming/java/ and a level above for the entire naming
package which might be of interest to you.

However, it is expected and supported that users use other
InitialContextFactories to connect to different remote servers via JNDI.
I routinely use the JBoss, OpenJMS, and Weblogic initial context
factories in exactly the manner in your code snippet, without a problem.
The client jar file for the remote server, which contains the initial
context factory implementation, should be in the WEB-INF/lib directory
of your web application.

Yoav Shapira
Millennium Research Informatics


>-----Original Message-----
>From: Sternbergh, Cornell [mailto:rsternberg@state.pa.us]
>Sent: Thursday, August 12, 2004 11:01 AM
>To: tomcat-user@jakarta.apache.org
>Subject: InitialContextFactory
>
>Short version:
>What's the initial context factory for Tomcat (for use in accessing DB2
>via db2cli for Windows via ODBC/JDBC)?
>
>Long version:
>
>I'm trying to evaluate Eclipse as an IDE for maintaining a Java project
>(applications/servlets/jsps), originally written using VAJ for use on
>Websphere.  I've gotten Tomcat 4.1 running on my machine, I've the
>sysdeo plugin for Eclipse, which seems to be a bridge to Tomcat, so one
>can deal with it in Eclipse.
>
>I deployed a previously existing war, via Tomcat manager, into
>%CATALINA_HOME%\webapps.
>
>Now, I can get to my first .JSP successfully :-), but...
>It's a form whose contents are then checked against a database (JDBC to
>ODBC to db2cli for Windows to Mainframe DB2).
>
>In our project.props file, we set JNDI.InitialContextFactory to:
>  com.ibm.ejs.ns.jndi.CNInitialContextFactory (for testing in VAJ's
WTE)
>and
>  com.ibm.websphere.naming.WsnInitialContextFactory (for production) on
>Websphere.
>
>The project's framework reads the .props file and sets various things,
>I've included a code snippet below.
>
>Right now, I'm trying to find/figure out what to use for an initial
>context factory, that's not an IBM class.  When I continue and try the
>form, with the IBM class,
>javax.naming.spi.NamingManager.getInitialContext throws a
>ClassNotFoundException on the IBM class (cause it's not there)
>
>So... the two application servers from IBM have different initial
>context factories, I'm assuming that Tomcat also has an initial context
>factory.  What is it?
>
>Or... Maybe I need something completely different ;-)
>
>Anyway, here's the code snippet showing the use of the
>JNDI.InitialContextFactory:
>
>...
>  try {
>    Hashtable initContextProps = new Hashtable();
>    initContextProps.put(javax.naming.Context.PROVIDER_URL,(String)
>configService.getProperty("JNDI.ProviderURL"));
>
>initContextProps.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,(Stri
n
>g) configService.getPropert("JNDI.InitialContextFactory"));
>    javax.naming.InitialContext context = new
>javax.naming.InitialContext(initContextProps);
>
>    DataSource ds =
>(DataSource)context.lookup(configService.getProperty("DB.DataSourceName
"
>));
>
>
>dbConn=ds.getConnection(configService.getProperty("DB.Userid"),configSe
r
>vice.getProperty("DB.Password"));
>  if (dbConn!=null) dbConn.setAutoCommit(false);
>
>
>TIA
>Cornell
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
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