Hi All,

Recently we started to write a LDAP client and observed following exception
when i create context instance.
context = new InitialDirContext(environment);

Error obtaining connection. Cannot find the InitialContextFactory
com.sun.jndi.ldap.LdapCtxFactory. javax.naming.NoInitialContextException:
Cannot find the InitialContextFactory com.sun.jndi.ldap.LdapCtxFactory.
at
org.wso2.carbon.jndi.internal.osgi.JNDIContextManagerImpl.lambda$getInitialContextInternal$20(JNDIContextManagerImpl.java:118)
at java.util.Optional.orElseThrow(Optional.java:290)
at
org.wso2.carbon.jndi.internal.osgi.JNDIContextManagerImpl.getInitialContextInternal(JNDIContextManagerImpl.java:118)
at
org.wso2.carbon.jndi.internal.osgi.JNDIContextManagerImpl.newInitialContext(JNDIContextManagerImpl.java:68)
at
org.wso2.carbon.jndi.internal.osgi.factory.DefaultContextFactory.lambda$getInitialContext$23(DefaultContextFactory.java:68)
at
org.wso2.carbon.jndi.internal.util.LambdaExceptionUtils.lambda$rethrowFunction$4(LambdaExceptionUtils.java:120)
at java.util.Optional.map(Optional.java:215)
at
org.wso2.carbon.jndi.internal.osgi.factory.DefaultContextFactory.getInitialContext(DefaultContextFactory.java:68)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)


I was able to get the context successfully using following workaround. But
since it is not the proper way can we have a way to solve this issue? It
seems carbon jndi cannot find the LdapCtxFactory.

LdapCtxFactory.getLdapCtxInstance(environment.get(Context.PROVIDER_URL),
environment);


Thanks and Regards

-- 
Rukshan Chathuranga.
Software Engineer.
WSO2, Inc.
+94711822074
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to