JNDI Support

  • Thread starter Patrick Ashley Meuser\-Bianca\
  • Start date
P

Patrick Ashley Meuser\-Bianca\

Can someone please tell me why JNDI Support at Sun does not exist for the
search term JNDI.jar and/or point me in the actual direction that I may
download this resource? It seems that JNDI support in "my JDK1.5" doesn't
exist either for the Context Factory in the environment that is described by
the tutorial (which does consequently reference the jndi.jar file), why, I
do not know.

Please and Thank-you,

Patrick Ashley Meuser"-Bianca"
Cyberneticist
 
E

EJP

Patrick said:
Can someone please tell me why JNDI Support at Sun does not exist for the
search term JNDI.jar and/or point me in the actual direction that I may
download this resource? It seems that JNDI support in "my JDK1.5" doesn't
exist either for the Context Factory in the environment that is described by
the tutorial (which does consequently reference the jndi.jar file), why, I
do not know.

There is no jndi.jar file in JDK 1.5. Presumably the tutorial is out of
date. However JNDI is certainly supported in 1.4 and 1.5, I've been
using it for years. What URL are you trying to use with the InitialContext.
 
P

Patrick Ashley Meuser\-Bianca\

Here's the code:

try
{
String name=args[0];
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.fscontext.RefFSContextFactory");

Context ctx = new InitialContext(env);
Object obj = ctx.lookup(name);
System.out.println(name + " is bound to: " + obj);
}
catch (Exception e)
{
e.printStackTrace();
}


I'm using for the local file system so their are no other links. The
exception is:

javax.naming.NoInitialContextException: Cannot instantiate class:
com.sun.jndi.f
scontext.RefFSContextFactory [Root exception is
java.lang.ClassNotFoundException
: com.sun.jndi.fscontext.RefFSContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at ClassManager.main(ClassManager.java:21)
Caused by: java.lang.ClassNotFoundException:
com.sun.jndi.fscontext.RefFSContext
Factory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
... 5 more
 
J

jupiter

Patrick Ashley Meuser"-Bianca" said:
Here's the code:

try
{
String name=args[0];
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.fscontext.RefFSContextFactory");

Context ctx = new InitialContext(env);
Object obj = ctx.lookup(name);
System.out.println(name + " is bound to: " + obj);
}
catch (Exception e)
{
e.printStackTrace();
}


I'm using for the local file system so their are no other links.
The exception is:

javax.naming.NoInitialContextException: Cannot instantiate class:
com.sun.jndi.f
scontext.RefFSContextFactory [Root exception is
java.lang.ClassNotFoundException

Patrick, you need RefFSContextFactory in your classpath.

Go to the link below and download JNDI support zip that contains
jars and classes that you need.

http://java.sun.com/products/jndi/downloads/index.html#DOWNLOAD12

Unzip fscontext.jar (and providerutil.jar too I think) (the only
jars in the zip) to JRE_HOME\lib\ext and it will be in your
classpath next time you go to runtime. The class cited in your
exception is in the fscontext.jar.

Good luck. You should be able to do file name lookups after fixing
that.
 
P

Patrick Ashley Meuser\-Bianca\

I tried both the %JAVA_HOME%/lib and %JAVA_HOME$/jre/lib/ext with the jar
you suggested. I downloaded and unzipped all the jars I could find and
tried running the program with the jars installed in both directories and I
had no success.

Patrick Ashley Meuser"-Bianca"
Cyberneticist

jupiter said:
Patrick Ashley Meuser"-Bianca" said:
Here's the code:

try
{
String name=args[0];
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.fscontext.RefFSContextFactory");

Context ctx = new InitialContext(env);
Object obj = ctx.lookup(name);
System.out.println(name + " is bound to: " + obj);
}
catch (Exception e)
{
e.printStackTrace();
}


I'm using for the local file system so their are no other links. The
exception is:

javax.naming.NoInitialContextException: Cannot instantiate class:
com.sun.jndi.f
scontext.RefFSContextFactory [Root exception is
java.lang.ClassNotFoundException

Patrick, you need RefFSContextFactory in your classpath.

Go to the link below and download JNDI support zip that contains jars and
classes that you need.

http://java.sun.com/products/jndi/downloads/index.html#DOWNLOAD12

Unzip fscontext.jar (and providerutil.jar too I think) (the only jars in
the zip) to JRE_HOME\lib\ext and it will be in your classpath next time
you go to runtime. The class cited in your exception is in the
fscontext.jar.

Good luck. You should be able to do file name lookups after fixing that.
 
J

jupiter

Patrick Ashley Meuser"-Bianca" said:
I tried both the %JAVA_HOME%/lib and %JAVA_HOME$/jre/lib/ext with
the jar you suggested. I downloaded and unzipped all the jars I
could find and tried running the program with the jars installed
in both directories and I had no success.

Patrick Ashley Meuser"-Bianca"
Cyberneticist

Patrick, if it's the same exception (can you post it?) then you
have a classpath issue. It was trying to find RefFSContextFactory,
which is in the jar that you copied.

The only thing I can think of is that you might have copied the
jars to the wrong JRE. Windows boxes usually have a default JRE
someplace under Program Files or something, and often that is the
version that is running from the prompt without anybody knowing it.
If you copied the jars to the *other* JRE destination then you are
not actually invoking it.

Work from the assumption that it's a classpath issue because your
code looks OK. I'd double check the package name you typed in your
code against the package in the jar too. It looks OK to me but
check the package name in the jar. Check the jar to assure
yourself that the class does exist. It does, it's just not getting
found by the JVM.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top