Topic
  • 10 replies
  • Latest Post - ‏2013-07-11T16:52:23Z by HP-ESP
MartinMotovsky
MartinMotovsky
2 Posts

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

‏2012-10-24T07:29:40Z |
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.

Nothing 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
Updated on 2013-04-03T11:45:04Z at 2013-04-03T11:45:04Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    37422 Posts

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

    ‏2013-01-03T15:02:25Z  
    Hi Martin - did you get an answer/solution to this? I'm hitting exactly the same problem and can't find anything other than complex classloading discussions!
  • MartinMotovsky
    MartinMotovsky
    2 Posts

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

    ‏2013-01-08T08:08:18Z  
    Hi Martin - did you get an answer/solution to this? I'm hitting exactly the same problem and can't find anything other than complex classloading discussions!
    Unfortunately I did not find the solution. Fortunately (for me only and I know that just temporarily), it was just a test, I did not need it immediately - so I put it away.
  • gduser
    gduser
    3 Posts

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

    ‏2013-02-05T14:38:56Z  
    Unfortunately I did not find the solution. Fortunately (for me only and I know that just temporarily), it was just a test, I did not need it immediately - so I put it away.
    I have the same problem. On WAS 8.0.0.5 it is working fine, on WAS 8.5.0.1 it is not.
  • SystemAdmin
    SystemAdmin
    37422 Posts

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

    ‏2013-03-11T22:03:51Z  
    • gduser
    • ‏2013-02-05T14:38:56Z
    I have the same problem. On WAS 8.0.0.5 it is working fine, on WAS 8.5.0.1 it is not.
    I am experiencing the exact same problem.
    "com.sun.jndi.ldap.LdapCtx incompatible with org.springframework.ldap.core.DirContextAdapter"
  • SystemAdmin
    SystemAdmin
    37422 Posts

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

    ‏2013-03-13T09:04:27Z  
    I am experiencing the exact same problem.
    "com.sun.jndi.ldap.LdapCtx incompatible with org.springframework.ldap.core.DirContextAdapter"
    I am using Websphere Application Server 8.5.0.1 and I am facing exactly the same problem:

    22.2.2013 8:41:58:397 EET 00000087 webapp E com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E: [S
    ervlet Error]-ServletNameNotFound: java.lang.ClassCastException: com.sun.jndi.ldap.LdapCtx incompatible with org.sprin
    gframework.ldap.core.DirContextAdapter
    at org.springframework.security.ldap.SpringSecurityLdapTemplate$2.mapFromContext(SpringSecurityLdapTemplate.java
    :158)
    at org.springframework.ldap.core.ContextMapperCallbackHandler.getObjectFromNameClassPair(ContextMapperCallbackHa
    ndler.java:67)
    at org.springframework.ldap.core.CollectingNameClassPairCallbackHandler.handleNameClassPair(CollectingNameClassP
    airCallbackHandler.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)

    Does anyone know a workaround for this, or whether it will be fixed in SP 2 ?

    Seems that the same LDAP problem with spring security has been also in WAS 8.0 but it has been fixed in 8.0.0.2.
    http://forum.springsource.org/showthread.php?122586-com-sun-jndi-ldap-LdapCtx-incompatible-with-org-springspringframework-ldap-core-DirCo

    I also found this workaround, but I dont think it's a good option to write all the ldap code again from scratch.
    http://www.ibm.com/developerworks/forums/message.jspa?messageID=14778529

    Has anyone managed to get the Spring Security LDAP stuff working in WAS 8.5 ?
  • SystemAdmin
    SystemAdmin
    37422 Posts

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

    ‏2013-03-13T13:27:47Z  
    I am using Websphere Application Server 8.5.0.1 and I am facing exactly the same problem:

    22.2.2013 8:41:58:397 EET 00000087 webapp E com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E: [S
    ervlet Error]-ServletNameNotFound: java.lang.ClassCastException: com.sun.jndi.ldap.LdapCtx incompatible with org.sprin
    gframework.ldap.core.DirContextAdapter
    at org.springframework.security.ldap.SpringSecurityLdapTemplate$2.mapFromContext(SpringSecurityLdapTemplate.java
    :158)
    at org.springframework.ldap.core.ContextMapperCallbackHandler.getObjectFromNameClassPair(ContextMapperCallbackHa
    ndler.java:67)
    at org.springframework.ldap.core.CollectingNameClassPairCallbackHandler.handleNameClassPair(CollectingNameClassP
    airCallbackHandler.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)

    Does anyone know a workaround for this, or whether it will be fixed in SP 2 ?

    Seems that the same LDAP problem with spring security has been also in WAS 8.0 but it has been fixed in 8.0.0.2.
    http://forum.springsource.org/showthread.php?122586-com-sun-jndi-ldap-LdapCtx-incompatible-with-org-springspringframework-ldap-core-DirCo

    I also found this workaround, but I dont think it's a good option to write all the ldap code again from scratch.
    http://www.ibm.com/developerworks/forums/message.jspa?messageID=14778529

    Has anyone managed to get the Spring Security LDAP stuff working in WAS 8.5 ?
    Hi, It sounds like you have something that works on V8.0.0.2 and not V8.5.0.1 so I think opening a PMR for the service team to look at would be the nest next step.
  • SystemAdmin
    SystemAdmin
    37422 Posts

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

    ‏2013-03-14T06:07:33Z  
    Hi, It sounds like you have something that works on V8.0.0.2 and not V8.5.0.1 so I think opening a PMR for the service team to look at would be the nest next step.
    Hi, yeah I think that would be a good thing to do next. I will find out whether someone in my organisation can raise the PMR ticket about this. Thank you!
  • SystemAdmin
    SystemAdmin
    37422 Posts

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

    ‏2013-04-03T11:45:04Z  
    Hi, yeah I think that would be a good thing to do next. I will find out whether someone in my organisation can raise the PMR ticket about this. Thank you!
    Hi, i am facing the same problem with

    Websphere
    Integrated Solutions Console, 8.5.0.1
    Build Number: cf011242.02
    Build Date: 10/17/12
    Is there anybody having a solution?
  • Hosehead
    Hosehead
    1 Post

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

    ‏2013-04-16T10:05:33Z  
    Hi, i am facing the same problem with

    Websphere
    Integrated Solutions Console, 8.5.0.1
    Build Number: cf011242.02
    Build Date: 10/17/12
    Is there anybody having a solution?

    Hello. I found the solution. Installing IBM iFix 8.5.0.0-WS-WASProd-IFPM74498 fixed the problem in WAS 8.5.0.0. Not sure whether the same fix can be installed in 8.5.0.1 though.

    Best regards,

    Hosehead

  • HP-ESP
    HP-ESP
    1 Post

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

    ‏2013-07-11T16:52:23Z  
    • Hosehead
    • ‏2013-04-16T10:05:33Z

    Hello. I found the solution. Installing IBM iFix 8.5.0.0-WS-WASProd-IFPM74498 fixed the problem in WAS 8.5.0.0. Not sure whether the same fix can be installed in 8.5.0.1 though.

    Best regards,

    Hosehead

    Thank you so much for posting this response. This helped fix my problem.

    Just an additional link for someone looking:

    http://www-01.ibm.com/support/docview.wss?uid=swg27036319

    This fix went into 8.5.0.2 looks like.