JNDI Problem (ClassNotFoundException: com.sun.jndi.fscontext.RefFSContextFactory)

i am currently doing some self-study in JNDI by using http://java.sun.com/products/jndi/tutorial/trailmap.html as my tutorial source.

i am using winxp and Java(TM) 2 SDK, Standard Edition Version 1.4.2.

i am able to complie the following example code successfully.
------------------------------------------------------------------------
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.Hashtable;

class Lookup {
    public static void main(String[] args) {
      // Check that user has supplied name of file to lookup
      if (args.length != 1) {
          System.err.println("usage: java Lookup <filename>");
          System.exit(-1);
      }

      String name = args[0];

      // Identify service provider to use
      Hashtable env = new Hashtable(11);
      env.put(Context.INITIAL_CONTEXT_FACTORY,
          "com.sun.jndi.fscontext.RefFSContextFactory");

      try {

          // Create the initial context
          Context ctx = new InitialContext(env);

          // Look up an object
          Object obj = ctx.lookup(name);

          // Print it out
          System.out.println(name + " is bound to: " + obj);
          
          // Close the context when we're done
          ctx.close();
      } catch (NamingException e) {
          System.err.println("Problem looking up " + name + ": " + e);
      }
    }
}
------------------------------------------------------------------------
however, when come to execution, i am stucked with the following exception.

C:\DOCUME~1\YANCHE~1\Desktop>dir c:\autoexec.bat
 Volume in drive C has no label.
 Volume Serial Number is 600C-73BF

 Directory of c:\

03/16/2004  04:40 AM                 0 AUTOEXEC.BAT
               1 File(s)              0 bytes
               0 Dir(s)  12,305,121,280 bytes free

C:\DOCUME~1\YANCHE~1\Desktop>java Lookup \
Problem looking up \: javax.naming.NoInitialContextException: Cannot instantiate
 class: com.sun.jndi.fscontext.RefFSContextFactory [Root exception is java.lang.
ClassNotFoundException: com.sun.jndi.fscontext.RefFSContextFactory]

i was wondering whether can i get the class file "com.sun.jndi.fscontext.RefFSContextFactory". i had gone trough the "Common Problems (and Their Solutions)" section under the tutorial. however, i didnt find a clear path on how can i solve this problem :(

any suggestion and solving this problem?

thank you.

regards
yan cheng
yccheokAsked:
Who is Participating?
 
bkfirebirdConnect With a Mentor Commented:
go to http://java.sun.com/products/jndi/downloads/index.html
click on download JNDI 1.2.1
download the File System Service Provider, that should have those files
0
 
bkfirebirdCommented:
add jndi.jar to your classpath
0
 
Tommy BraasCommented:
You have to look for something at a known path and you have to have a JNDI server running. If you download either J2EE SDK 1.3 or 1.4 you will get a JNDI server.
0
 
yccheokAuthor Commented:
i am using J2SE 1.4 SDK standard addition and olso the J2EE 1.4 SDK. i oledi include jndi.jar in my classpath which come with J2EE 1.4 SDK, still didnt work.

from other forum, i realize that i need the following files in my classpath
fscontext.jar
providerutil.jar

how can i get the above files?

thank you.

regards
yan cheng
0
 
Tommy BraasConnect With a Mentor Commented:
Do you have the Sun Java System Application Server Platform Edition 8 running? Do you have JNDI names defined in the server? Are you trying to get the context for any of the defined names in the JNDI directory? When getting the initial context from JNDI when you're running your application and server on the same machine can be done with the default constructor for InitialContext, i.e. new InitialContext();
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.