[jboss-user] [Beginners Corner] - JNDI/OpenLdap ClassCastException

Argy do-not-reply at jboss.com
Sun Aug 6 07:43:13 EDT 2006


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? 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3963426#3963426

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3963426



More information about the jboss-user mailing list