Topic
  • 2 replies
  • Latest Post - ‏2012-10-22T13:39:38Z by MartinMotovsky
MartinMotovsky
MartinMotovsky
5 Posts

Pinned topic WAS(8.5) + Spring Security: Using an LDAP Authentication Provider

‏2012-10-17T14:30:39Z |
Hello all,
I have tested this simple tutorial "Spring Security - MVC: Using an LDAP Authentication Provider":
http://krams915.blogspot.co.at/2011/01/spring-security-mvc-using-ldap.html

I am able to run it successfully at Tomcat, Glassfish, even at WAS8.5 Liberty Profile. But when I run it at the full WAS profile, I experience the following exception:
java.lang.ClassCastException: com.sun.jndi.ldap.LdapCtx incompatible with org.springframework.ldap.core.DirContextAdapter
at org.springframework.security.ldap.SpringSecurityLdapTemplate$2.mapFromContext(SpringSecurityLdapTemplate.java:157)
at org.springframework.ldap.core.ContextMapperCallbackHandler.getObjectFromNameClassPair(ContextMapperCallbackHandler.java:67)
at org.springframework.ldap.core.CollectingNameClassPairCallbackHandler.handleNameClassPair(CollectingNameClassPairCallbackHandler.java:50)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:297)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:259)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:606)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:524)
at org.springframework.security.ldap.SpringSecurityLdapTemplate.searchForSingleAttributeValues(SpringSecurityLdapTemplate.java:172)
...

After the surfing at Internet, I tried the following:
a)
In the Administrative Console,
Server-specific Application Settings -> Classloader policy I set up: Single.
Server-specific Application Settings -> Class loading mode: I tried both options - "Classes loaded with parent class loader first" as well as "Classes loaded with local class loader first (parent last)"
I have restarted server after each change.

b)
I found a recommendation to set up a custom property
com.ibm.ws.webcontainer.invokefilterscompatibility = true
in the Administrative Console -> Application servers -> my server -> Web container -> Customer properties.
Noting from the above helped.
I have noticed, that when I see into the Class loader viewer, the class com.sun.jndi.ldap.LdapCtxFactory is loaded by two classloaders:
1) Extension - com.ibm.ws.bootstrap.ExtClassLoader
and also by
2) Module - com.ibm.ws.classloader.CompoundClassLoader

I guess, that the above information could help to solve the problem.

Thanks for the hint how to step forward.
Martin
  • Jacek_Laskowski
    Jacek_Laskowski
    133 Posts

    Re: WAS(8.5) + Spring Security: Using an LDAP Authentication Provider

    ‏2012-10-19T08:57:47Z  
    Hi,

    It'd be more rewarding if the issue were reported to the full WebSphere Application Server forum. "This forum is for the WASdev community members to interact with each other and with the WAS development staff on questions and issues related to the WASdev community (wasdev.net)."

    Jacek
    Japila :: verba docent, exempla trahunt
  • MartinMotovsky
    MartinMotovsky
    5 Posts

    Re: WAS(8.5) + Spring Security: Using an LDAP Authentication Provider

    ‏2012-10-22T13:39:38Z  
    Hi,

    It'd be more rewarding if the issue were reported to the full WebSphere Application Server forum. "This forum is for the WASdev community members to interact with each other and with the WAS development staff on questions and issues related to the WASdev community (wasdev.net)."

    Jacek
    Japila :: verba docent, exempla trahunt
    Thank you Jacek for your navigation to the right forum place. I will copy my question to the recommended forum. Although the true is, that I encountered that issue during my development work using WAS as development application server. The topic of my submission is Spring + LDAP + WAS, which is e.g. quite similar to your submission https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14896365&#14896365 which is also about LDAP + WAS(Liberty Profile).

    Martin