Solved

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

Posted on 2004-04-12
7
10,450 Views
Last Modified: 2013-11-24
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
0
Comment
Question by:yccheok
  • 2
  • 2
7 Comments
 
LVL 4

Expert Comment

by:bkfirebird
ID: 10808516
add jndi.jar to your classpath
0
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 10808823
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
 

Author Comment

by:yccheok
ID: 10809721
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
 
LVL 4

Accepted Solution

by:
bkfirebird earned 35 total points
ID: 10809744
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
 
LVL 14

Assisted Solution

by:Tommy Braas
Tommy Braas earned 35 total points
ID: 10809775
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

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now