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

Pinned topic Websphere 8.0 and Spring LDAP ClassCastException

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

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 com.sentera.fi.slo.webshop.facade.LdapFacade - java.lang.ClassCastException: com.sun.jndi.ldap.LdapCtx incompatible with org.springframework
.ldap.core.DirContextOperations
at org.springframework.ldap.core.LdapEntryIdentificationContextMapper.mapFromContext(LdapEntryIdentificationContextMapper.java:28)
at org.springframework.ldap.core.ContextMapperCallbackHandler.getObjectFromNameClassPair(ContextMapperCallbackHandler.java:67)
at org.springframework.ldap.core.CollectingNameClassPairCallbackHandler.handleNameClassPair(CollectingNameClassPairCallbackHandler.java:50)
Updated on 2012-01-25T15:56:14Z at 2012-01-25T15:56:14Z by Condor70
  • Condor70
    Condor70
    1 Post

    Re: Websphere 8.0 and Spring LDAP ClassCastException

    ‏2012-01-25T15:56:14Z  
    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 (http://forum.springsource.org/showthread.php?73576-Getting-ClassCastException-even-when-I-am-not-using-custom-DirObjectFactory&p=246643#post246643) 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:
    java.naming.factory.object=org.springframework.ldap.core.support.DefaultDirObjectFactory

    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.

    Workaround:
    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).