Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2006

Tip: Looking for answers? Try searching our database.

JNDI Support

Thread view: 
Patrick Ashley Meuser"-Bianca" - 29 Dec 2006 20:50 GMT
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
EJP - 30 Dec 2006 01:36 GMT
> 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.
Patrick Ashley Meuser"-Bianca" - 30 Dec 2006 02:54 GMT
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

>> 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
[quoted text clipped - 6 lines]
> 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.
jupiter - 30 Dec 2006 05:42 GMT
> Here's the code:
>
[quoted text clipped - 21 lines]
> 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.
Patrick Ashley Meuser"-Bianca" - 30 Dec 2006 15:22 GMT
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

>> Here's the code:
>>
[quoted text clipped - 35 lines]
>
> Good luck.  You should be able to do file name lookups after fixing that.
jupiter - 31 Dec 2006 04:23 GMT
>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
[quoted text clipped - 3 lines]
> 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.