Solved

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

Posted on 2004-04-12
7
11,086 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 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
couple of eclipse 5 52
spring jars download 1 52
Notify sent to other threads in Java 9 42
jmeter usage 4 35
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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 about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This video teaches viewers about errors in exception handling.

756 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