Skip to main content
Level 3
Nov 2, 2016 9:05 PM UTC
Solved

LDAP Serach Error - NotContextException

Hi All,

We are upgarding from CQ5.6.1 to AEM 6.2. In the earlier version we had a code that search the content of Ldap using javax.naming.directory* classes.

Like the way

DirContext ctx = new InitialDirContext(env); //Creating context NamingEnumeration<SearchResult> ldapResults = ctx.search(base.get(), filter, sc); //Calling search method with arguments, this line throws Exception

When we are running the same code in AEM 6.2, getting the error.

javax.naming.NotContextException: Not an instance of DirContext at javax.naming.directory.InitialDirContext.getURLOrDefaultInitDirCtx(InitialDirContext.java:111) at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:267)

Any one faced this issue? The only difference I know is that in Cq5.6.1, we used to do the LDAP configs at server level, in AEm 6.2 they are available in OSGI configs.

Note:- We are defaining the LDAP enviornment varaibles in the Java class as well where we are getting the exception

Thanks

Monika

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Sham_HC
Sham_HCAccepted solution
Level 10
Nov 3, 2016 2:24 AM UTC

Hi Monika,

Osgi is an JNDI implementation does not interact well with factory DirContext or LdapContext for casting it back. You can find couple of issue in web on this with various osgi providers. To over come this make use of enhanced LDAP API which replaces JNDI and the existing LDAP API like "schema aware" API with convenient ways to access any LDAP server.

 

Thanks,

15 replies

Level 3
Jul 5, 2019 5:17 PM UTC

I have embedded the jar inside my bundle to solve this issue. I could not get through any other options.

Regards,

Dinesh kumar L.

Translate
Level 2
Jul 5, 2019 5:05 PM UTC

I have this same issue

org.apache.directory.ldap.client.api -- Cannot be resolved

did you ever get it solved?

I have read you can take any jar and wrap it to for use as a bundle but I really want this to be self contained.

Thanks

Translate
Level 3
Nov 2, 2018 8:15 AM UTC

Hi Sham, Monika,

I am trying to use LDAP API 2.0 in AEM 63 SP2 for our requirement. My maven build is getting succeed but bundle is not getting resolved after uploading it to felix console. Below highlighted packages are not getting resolved. Did you face similar issue?

org.apache.directory.api.ldap.model.exception -- Cannot be resolved

org.apache.directory.ldap.client.api -- Cannot be resolved

Thanks,

Dinesh Kumar L.

Translate
monikaa6Author
Level 3
Nov 7, 2016 2:47 PM UTC

Thanks Sham. Thats very helpful!!

Translate
Sham_HC
Sham_HCAccepted solution
Level 10
Nov 3, 2016 2:24 AM UTC

Hi Monika,

Osgi is an JNDI implementation does not interact well with factory DirContext or LdapContext for casting it back. You can find couple of issue in web on this with various osgi providers. To over come this make use of enhanced LDAP API which replaces JNDI and the existing LDAP API like "schema aware" API with convenient ways to access any LDAP server.

 

Thanks,

Translate