Zvika,
OK, I understand now. Are the implementations of the JNDI spec usually
found in the JDBC drivers, or are they found in the JSP/Servlet Servers? Or
can they be found in both?
The connection pool I am trying to use is a set of classes found in the Type
IV JDBC driver that we purchased for SQLServer 2000. We are using
AveConnect's 2.5 Driver with Extended API. They have an addition class,
called JDBCConnectionPoolDataSource, on top of the Java Extended API, that
implements a connection pool as follows:
public class JDBCConnectionPoolDataSource
extends JDBCDataSource
implements javax.sql.ConnectionPoolDataSource
As I mentioned, I've not really worked with or used the JNDI very much, and
the tutorial on the Sun site was not clear as to the fact that the JDK
jndi.jar file was only the interface, and that the implementation is left to
third party vendors. I guess if I had looked at the Java API document for
JNDI, I would have come to that conclusion. But when your under the gun,
you sometimes cut corners and just ask for advice.
Thanks again for the clarification.
Celeste
-----Original Message-----
From: Zvika Markfeld [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 15, 2002 11:36 PM
To: [EMAIL PROTECTED]
Subject: Re: Using JNDI in a JSP/Servlet
Hi Celeste,
JNDI is a spec provided by Sun for Naming Managers. Various 3rd Party
Vendors offer their Naming manager implementations, some of which support
the JNDI spec. When including jndi.jar from your JDK files, you are
including the spec but not any concrete implementation. Since you _are_
trying to connect to a real naming manager, there should be a another
jar/library containing those real implementation classes.
The INITIAL_CONTEXT_FACTORY param that you are using, however, is the one
used for Sun's reference implementation of a naming manager utilizing a file
system (which is a valid naming server) - so you would probably want to dig
some more into your documentation and find a real example. btw are you using
a connection pool on iPlanet?
zvika.
When saying JNDI provider classes I am refering to those classes that were
supplied by the JNDI service implementor, such as
com.sun.jndi.fscontext.RefFSContextFactory. BTW how come you're using
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Haseltine, Celeste
Sent: Wednesday, January 16, 2002 2:16 AM
To: [EMAIL PROTECTED]
Subject: Re: Using JNDI in a JSP/Servlet
Zvika,
When you mention "Java provider classes", are you referring to classes that
should be in my third party driver's jar file? The only jndi jar file I
have in my classpath is the one included in the JDK from Sun. The test
servlet I was using came out of the vendors examples files that they ship
with the driver. They are pretty much incomplete, so if this is an error
being thrown from the vendors jar file, I'll post this with their tech
support group. Or are you referring to something else?
Celeste
-----Original Message-----
From: Zvika Markfeld [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 15, 2002 5:29 PM
To: [EMAIL PROTECTED]
Subject: Re: Using JNDI in a JSP/Servlet
the exception means that the nitialContextFactory object specified in your
env cannot be located. This might be due to the fact that your jndi.jar
contains only the interfaces that are related to jndi (that is, package
javax.naming and related packages) but not the JNDI provider classes. you
need to add to your classpath these classes, that are usually bundled with
the Naming Manager you are trying to access.
zm.
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Haseltine, Celeste
Sent: Wednesday, January 16, 2002 1:07 AM
To: [EMAIL PROTECTED]
Subject: Using JNDI in a JSP/Servlet
I'm attempting to use JNDI with a third party JDBC driver inside of a
servlet. When I attempt to call the servlet, my catch block catches the
following error message:
Error ..... Cannot instantiate class:
com.sun.jndi.fscontext.RefFSContextFactory
I moved the code into a pure Java class for debugging. The line that the
error message occurs on is as follows:
ctx = new InitialContext(env);
Does anyone have a guess as to why I am unable to instantiate a new Context
class? I suspect it may have to do with setting permissions for jndi, but I
am not certain. I do have the JNDI.jar file in my server jvm jre\lib\ext
subdirectory, and I moved it into my jdk jre\lib\ext subdirectory for
debugging the class code. Just for grins I included the jdk jre\lib\ext
path in my dev box classpath for testing the class code. The class code is
as follows:
import java.sql.*;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;
import net.avenir.jdbcPool.*;
import java.util.Hashtable;
public class DataSourceTest{
public static void main(String[] argv){
System.out.println("got to beginning");
Context ctx =null;
System.out.println("got to 1");
try{
JDBCConnectionPoolDataSource cpds1 = new
JDBCConnectionPoolDataSource();
System.out.println("got to 2");
//cpds1.setServerName("");
cpds1.setDatabaseName("Northwind");
cpds1.setPort(1433);
Hashtable env = new Hashtable(11);
System.out.println("got to 3");
env.put
(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContextFactory
");
System.out.println("got to 4");
env.put(Context.PROVIDER_URL,"file:/");
System.out.println("got to 5");
ctx = new InitialContext(env); //THIS IS THE LINE THE
ERROR OCCURS ON
System.out.println("got to 6");
ctx.rebind("jdbc:pool:poolDS",cpds1);
System.out.println("got to 7");
JDBCDataSource ds1=new JDBCDataSource();
ds1.setDataSourceName("jdbc:pool:poolDS");
env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContext
Factory");
env.put(Context.PROVIDER_URL,"file:/");
ctx = new InitialContext(env);
ctx.rebind("jdbc:datasource",ds1);
} catch(Exception e) {
System.out.println("Error ..... "+e.getMessage());
}
}//end main
}//end class definition
Thanks in advance for any advice/suggestions.
Celeste
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com