<font color=red>javax.naming.NoInitialContextException</font> when trying to bind a datasource with JNDI
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   sabu_vs
Posted On:   Tuesday, May 21, 2002 08:46 PM

Hi I have created a datasource and try to bind it with JNDI but got an werror as follows javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.jndi.f scontext.RefFSContextFactory [Root exception is java.lang.ClassNotFoundException : com.sun.jndi.fscontext.RefFSContextFactory] The I code I used is below import com.microsoft.jdbcx.sqlserver.SQLServerDataSource; import javax.sql.*; import java.sql.*; import javax.naming.*; import javax.naming.directory.*; import java.util.Hashtable; public class Data { public static void ma   More>>

Hi



I have created a datasource and try to bind it with JNDI but got an werror as follows



javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.jndi.f
scontext.RefFSContextFactory [Root exception is java.lang.ClassNotFoundException
: com.sun.jndi.fscontext.RefFSContextFactory]




The I code I used is below




import com.microsoft.jdbcx.sqlserver.SQLServerDataSource;



import javax.sql.*;

import java.sql.*;

import javax.naming.*;

import javax.naming.directory.*;

import java.util.Hashtable;



public class Data

{

public static void main(String argv[])

{

try {

// Set up data source reference data for naming context:

// ----------------------------------------------------

// Create a class instance that implements the interface

// ConnectionPoolDataSource


SQLServerDataSource ds=new SQLServerDataSource();



ds.setDescription(

"MSSQLData Source");

ds.setServerName("localhost");

ds.setPortNumber(1521);

ds.setUser("scott");

ds.setPassword("test");


// Set up environment for creating initial context

Hashtable env = new Hashtable();

env.put(Context.INITIAL_CONTEXT_FACTORY,

"com.sun.jndi.fscontext.RefFSContextFactory");

env.put(Context.PROVIDER_URL, "file:c:\JDBCDataSource");

Context ctx = new InitialContext(env);


// Register the data source to JNDI naming service

ctx.bind("jdbc/PooledSparkyOracle", ds);


} catch (Exception e) {

System.out.println(e);

return;

}

} // Main

} //





Could you pls tell me what is the problem



thanks


sabu

   <<Less

Re: <font color=red>javax.naming.NoInitialContextException</font> when trying to bind a datasource with JNDI

Posted By:   Anonymous  
Posted On:   Thursday, May 23, 2002 01:54 AM

Try putting the enviroment setup for the initial context
before anything else, at the start of your try
statement.
About | Sitemap | Contact