• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Naming Problem

 
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone
I wrote the jndi program .Its compiled ok when i run this pgm i got the following exception.
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);
System.out.println("::::::::"+env);
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContextFactory");

try {
Context ctx = new InitialContext(env);
System.out.println("context is :"+ctx);
Object obj = ctx.lookup(name);
System.out.println("Object is :"+obj);
System.out.println(name + " is bound to: " + obj);
ctx.close();
} catch (NamingException e) {
System.err.println("Problem ******* looking up " + name + ": " + e);
}
}
}
Exception;
-----------
Problem ******* looking up \fx.bat: javax.naming.NoInitialContextException: Cann
ot instantiate class: com.sun.jndi.fscontext.RefFSContextFactory [Root exception
is java.lang.ClassNotFoundException: com.sun.jndi.fscontext.RefFSContextFactory
]

Note:
Here i got the pbm this progrsm i think
(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContextFactory
I mean com.sun.jndi.fsc.........
So how can i find out whethere the parameter is there or not i mean com.sun.jndi.fscontext.RefFSContextFactory

so any body advise...........
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check your classpath and add the approprate jar for com.sun.jndi.fscontext.RefFSContextFactory (jndi.jar).
Read this:
http://java.sun.com/products/jndi/tutorial/getStarted/examples/naming.html
 
Graham Thorpe
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes i downloaded the jndi.jar from sun.and i set the classpath too like this
set classpath=%classpath%;c:\jndi.jar;
Even though i got the exception what i send before .
Any advice pls.
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh so simple reddy ..!
put fscontext.jar and providerutil.jar in
your classpath.
U either include them in your CLASSPATH variable
or install them as extensions.
have a try..
 
It wasn't my idea to go to some crazy nightclub in the middle of nowhere. I just wanted to stay home and cuddle with this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic