Search code examples
springjboss7.xjndiopenamopendj

OpenAM with OpenDJ - NameNotFoundException: ldap/idp/userDN - when starting up JBoss


I'm using OpenAM, with its embedded OpenDJ as the LDAP service, to protect my web application running on JBoss 7.

When I start my JBoss I get this error:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ldapUserDN'
...
Caused by: javax.naming.NameNotFoundException: ldap/idp/userDN -- service jboss.naming.context.java.ldap.idp.userDN

So apparently Spring is looking for the JNDI node ldap/idp/userDN. But the jboss configuration file that I got with the project has these entries:

            <simple name="ldap/opendj/url" value="ldap://localhost:50389"/>
            <simple name="ldap/opendj/userDN" value="cn=Directory Manager"/>
            <simple name="ldap/opendj/password" value="mypassword"/>
            <simple name="ldap/opendj/baseDN" value="dc=opensso,dc=java,dc=net"/>

And these properties are added to my JNDI tree on JBoss.

If I change these to "ldap/idp/userDN", for instance, then I get rid of the error, but I was wondering if there's anywhere, where "ldap/opendj/userDN" should be mapped to "ldap/idp/userDN", that I've missed.


Solution

  • If you're using Spring LDAP, the actual configuration of the ldap-context-source goes in the a spring config file, and might look like this:

    <jee:jndi-lookup jndi-name="ldap/idp/url" id="ldapUrl"/>
    <jee:jndi-lookup jndi-name="ldap/idp/userDN" id="ldapUserDN"/>
    <jee:jndi-lookup jndi-name="ldap/idp/password" id="ldapPassword"/>
    <jee:jndi-lookup jndi-name="ldap/idp/baseDN" id="ldapBaseDN"/>
    <ldap:context-source url="#{ldapUrl}"  
        username="#{ldapUserDN}"
        password="#{ldapPassword}"      
        base="#{ldapBaseDN}"
        native-pooling="true"/>
    

    So the jndi entries in your jboss config file should match the ones above.