0 Replies Latest reply on Aug 6, 2006 7:43 AM by argy

    JNDI/OpenLdap ClassCastException

    argy

      Hi there,

      I have managed to get openldap setup with jboss connecting to it (by the method of editing jboss-service.xml and a properties file).

      Properties file:

      java.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory
      java.naming.provider.url=ldap://localhost:389/dc=testing,dc=com
      java.naming.security.principal=cn=Manager,dc=testing,dc=com
      java.naming.security.authentication=simple
      java.naming.security.credentials=secret
      


      addition to jboss-service.xml:
       <mbean code="org.jboss.naming.ExternalContext" name=":service=ExternalContext,jndiName=/ldap/configuration" >
       <attribute name="JndiName">/ldap/configuration</attribute>
       <attribute name="PropertiesURL">configuration.ldap</attribute>
       <attribute name="InitialContext">javax.naming.directory.InitialDirContext</attribute>
       <attribute name="RemoteAccess">true</attribute>
       </mbean>
      


      This all seems to work fine as when I start up Jboss I can see openldap logging say that a manager has connected.

      In my servlet however I try to look up the JNDI resource.

       InitialDirContext iniCtx = new InitialDirContext();
       Object ldap = iniCtx.lookup("/ldap/configuration");
      


      This works fine, but I am not sure what to cast it as. I try casting as LdapCtxFactory and I get a java.lang.ClassCastException: $Proxy61

      Any ideas?