Hi Everyone,
I am using standalone Java class (Main method) to look up a Datasource
in a database and I am using Netbeans IDE bundled Sunserver 8.2 , with
Derby database. I am facing exception in creating Initial Context. The
code snippet is as follows:
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");
InitialContext ctx = new InitialContext(env);
DataSource ds = (DataSource) ctx.lookup("jdbc/coffeeBreak");
Connection con = ds.getConnection("admin", "admin");The exception is l get is
Exception
in thread "main" javax.naming.NoInitialContextException: Cannot
instantiate class: com.sun.jndi.fscontext.RefFSContextFactory [Root exception is java.lang.ClassNotFoundException: com.sun.jndi.fscontext.RefFSContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java
:657)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:197)
at javaapplication1.Main.main(Main.java:171)
Is the Factory classname correct, what is the error? What PROVIDER_URL should i provide in the environment variable?
I have included j2ee.jar
in the lib but still I get "ClassNotFoundException"
Pls Help,
Deepa
===========================================================================
To unsubscribe, send email to
listserv@... and include in the body
of the message "signoff JNDI-INTEREST". For general help, send email to
listserv@... and include in the body of the message "help".