?
Solved

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

Posted on 2004-04-12
7
Medium Priority
?
11,835 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 140 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 140 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

719 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