• 1 reply
  • Latest Post - ‏2012-01-25T15:56:14Z by Condor70
6420 Posts

Pinned topic Websphere 8.0 and Spring LDAP ClassCastException

‏2012-01-16T09:36:43Z |

I hava an applicaiton which works fine on Tomcat 7, but on Websphere 8.0 the Spring class org.springframework.ldap.core.LdapTemplate.authenticate throws an ClassCastException.

Any idea's links will be appreciated! \O/

2012-01-12 12:11:39,266 WebContainer : 1 DEBUG - java.lang.ClassCastException: com.sun.jndi.ldap.LdapCtx incompatible with org.springframework
at org.springframework.ldap.core.LdapEntryIdentificationContextMapper.mapFromContext(
at org.springframework.ldap.core.ContextMapperCallbackHandler.getObjectFromNameClassPair(
at org.springframework.ldap.core.CollectingNameClassPairCallbackHandler.handleNameClassPair(
Updated on 2012-01-25T15:56:14Z at 2012-01-25T15:56:14Z by Condor70
  • Condor70
    1 Post

    Re: Websphere 8.0 and Spring LDAP ClassCastException

    Ran into the same problem this week.

    Spent way to much time on this but wasn't able to solve the problem, but did find a workaround.

    Found this link ( but the solution doesn't seem to work (my context class loader was already set to the EAR loader, so it should be able to find the spring-ldap jar).

    Background info:
    spring-ldap specifies an object factory when creating the JDNI LDAP context:

    But somehow JNDI isn't able to resolve the classname and reverts to the default object factory (that creates LdapCtx objects).
    I think this has something to do with the fact that OSGi is now integrated in WAS8 and that the OSGi classloaders are breaking this.

    I finally ended up rewriting my LDAP code so it uses AttributesMapper, BasicAttributes and ModificationItem[] instead of ContextMapper, DirContextAdapter and DirContextOperations (which is the recommended method for spring-ldap-1.3 anyway).