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