Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Cannot instantiate class: javax.naming.spi.InitialContextFactory

592 views
Skip to first unread message

Daniel Alex Finkelstein

unread,
Jul 26, 1999, 3:00:00 AM7/26/99
to
I'm using JDK 1.2.2 with the Java Plug-in to Netscape Communicator 4.61
on NT 4.0 sp5 and JNDI 1.2.

When trying to run my applet, the following appears in my java console:

javax.naming.NoInitialContextException: Cannot instantiate class:
javax.naming.spi.InitialContextFactory. Root exception
is java.lang.ClassNotFoundException:
javax/naming/spi/InitialContextFactory

However, in my code I have

import javax.naming.*;
import javax.naming.directory.*;
import javax.naming.directory.InitialDirContext;
import javax.naming.directory.DirContext;
import javax.naming.spi.InitialContextFactory;

[snip]

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"javax.naming.spi.InitialContext
Factory");
env.put(Context.PROVIDER_URL,"ldap://entrust.wisdom.siac.com:389");
DirContext ctx = new InitialDirContext(env);

and the class in question is in the jar file I have, with the directory
structure intact. Any ideas what I'm doing wrong?

Thanks.

--
Daniel Alex Finkelstein
New Technologies
Securities Industry Automation Corporation
http://www.siac.com


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

Scott Seligman

unread,
Jul 26, 1999, 3:00:00 AM7/26/99
to
Daniel Alex Finkelstein <dfin...@siac.com> writes:
>
> I'm using JDK 1.2.2 with the Java Plug-in to Netscape Communicator 4.61
> on NT 4.0 sp5 and JNDI 1.2.
>...
> env.put(Context.INITIAL_CONTEXT_FACTORY,"javax.naming.spi.InitialContextFactory");

This property's value should be "com.sun.jndi.ldap.LdapCtxFactory",
and the corresponding JAR files must be in the browser's classpath
(download the LDAP service provider for JNDI).


>import javax.naming.directory.InitialDirContext;
>import javax.naming.directory.DirContext;
>import javax.naming.spi.InitialContextFactory;

You can omit these lines.


Scott Seligman
Java Software Engineering
Sun Microsystems

Daniel Alex Finkelstein

unread,
Jul 27, 1999, 3:00:00 AM7/27/99
to
In article <7nimbb$g3q$1...@engnews3.Eng.Sun.COM>,

Scott Seligman <seli...@eng.sun.com> wrote:
> This property's value should be "com.sun.jndi.ldap.LdapCtxFactory",
> and the corresponding JAR files must be in the browser's classpath
> (download the LDAP service provider for JNDI).
>
> >import javax.naming.directory.InitialDirContext;
> >import javax.naming.directory.DirContext;
> >import javax.naming.spi.InitialContextFactory;
>
> You can omit these lines.

Done.

> Scott Seligman
> Java Software Engineering
> Sun Microsystems
>

I added an import line

import javax.naming.ldap.*;

And the java console now reports:

javax.naming.NoInitialContextException: Cannot instantiate class:
com.sun.jndi.ldap.LdapCtxFactory. Root exception is
java.lang.ClassNotFoundException: com/sun/jndi/ldap/LdapCtxFactory

The class is in the correct directory structure in the jar.

0 new messages