Hi,

i try to connect to a LDAP server (Netscape) within a servlet. But when
creating the InitialDirContext a ClassNotFoundException is thrown:

try {
        Properties p = new Properties();
        p.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory" );
        p.put(Context.PROVIDER_URL, "ldap://localhost:389/airius.com");
        ctx = new InitialDirContext(p);
} catch( Exception e ) {
        e.printStackTrace();
        throw new ServletException(e.getMessage());
}

results in the following output:

javax.naming.NoInitialContextException: Cannot instantiate class:
com.sun.jndi.ldap.LdapCtxFactory.  Root exception is java.lang.ClassNotFoundException: 
com.sun.jndi.ldap.LdapCtxFactory
        at java.net.URLClassLoader$1.run(URLClassLoader.java, CompiledCode)
        at java.lang.Exception.<init>(Exception.java, Compiled Code)
        
atjava.lang.ClassNotFoundException.<init>(ClassNotFoundException.java,CompiledCode)
        at java.net.URLClassLoader$1.run(URLClassLoader.java, CompiledCode)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java,Compiled Code)
        at java.lang.ClassLoader.loadClass(ClassLoader.java, CompiledCode)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java,Compiled Code)
        at java.lang.ClassLoader.loadClass(ClassLoader.java, CompiledCode)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:199)
        at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:45)
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:659)
        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:242)
        at javax.naming.InitialContext.init(InitialContext.java:218)
        at javax.naming.InitialContext.<init>(InitialContext.java:194)
        at javax.naming.directory.InitialDirContext.<init>(InitialDirContext.java:87)
        at tests.LDAPServlet.init(LDAPServlet.java:87)
        at javax.servlet.GenericServlet.init(GenericServlet.java:253)
        at com.evermind.server.http.HttpApplication.l2(JAX, CompiledCode)
        at com.evermind.server.http.HttpApplication.lu(JAX)
        at com.evermind.server.http.HttpApplication.kk(JAX, CompiledCode)
        at c_.k2(JAX, Compiled Code)
        at c.run(JAX, Compiled Code)

i've copied ldap.jar and providerutils.jar from SUN's LDAP SPI into
Orion's lib-directory.

What's wrong in my configuration???

Regards,

Georg Willmann

Reply via email to