Skip to main content



      Home
Home » Eclipse Projects » Virgo » Spring LDAP and exporting the service
Spring LDAP and exporting the service [message #640211] Fri, 19 November 2010 10:33 Go to next message
Eclipse UserFriend
Hi there,

currently I'm using Spring LDAP 1.3.0 for a module. I've build a service which simply returns all ldap groups as a List<Group> where Group is an interface which is provided in my context. Now something weird happens, if I export the ldap service.

<osgi:reference ref="ldapService" interface="eu.gue.LdapService" />


The service is consumed by the second package but here my problem starts, everytime I try to trigger a service method I recieve this kind of exception

java.lang.ClassCastException: com.sun.jndi.ldap.LdapCtx cannot be cast to org.springframework.ldap.core.DirContextOperations
	org.springframework.ldap.core.support.AbstractContextMapper.mapFromContext(AbstractContextMapper.java:43)
	org.springframework.ldap.core.ContextMapperCallbackHandler.getObjectFromNameClassPair(ContextMapperCallbackHandler.java:67)
	org.springframework.ldap.core.CollectingNameClassPairCallbackHandler.handleNameClassPair(CollectingNameClassPairCallbackHandler.java:50)
	org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:297)
	org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:237)
	org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:624)
	org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:535)
	org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:462)
	org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:483)
	org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:503)


I've got several other services running in my application which are working as intended. Why I'm receiving this exception here?

Adding the spring ldap bundle to the consuming service doesn't resolve the problem.
Re: Spring LDAP and exporting the service [message #640366 is a reply to message #640211] Sun, 21 November 2010 00:18 Go to previous messageGo to next message
Eclipse UserFriend
That really is a weird one. You could try asking on the relevant Spring forum where the Spring LDAP internals are understood. Failing that, I'd use a debugger to dig into the class cast exception. Usually this comes from a situation where multiple versions of a class are available and the wrong one is being used to cast. Evaluating expressions like obj.getClass().getClassLoader() is often revealing.

This case is atypical though because it mentions a Sun implementation class and so I wonder how that is leaking out, although that may be reasonable to someone who understands Spring LDAP internals.

Hope that's some help!
Re: Spring LDAP and exporting the service [message #640914 is a reply to message #640211] Tue, 23 November 2010 09:32 Go to previous message
Eclipse UserFriend
Onur,

Did you end up re-bundling spring-ldap 1.3.0? If you got that package from http://ebr.springsource.com/repository/app/bundle/version/de tail?name=org.springframework.ldap&version=1.3.0.RELEASE (Spring Source Bundle Repository) it limits version range for Spring Framework imports to [2.5.6.SEC01, 3.0.0). That is excluding Spring 3.x.

When I ended up re-bundling the ldap jar to get it to work with 3.x Spring, I set resolution to optional on com.sun.jndi.ldap.

Seems to work fine here with both OpenLDAP and ActiveDirectory. We are using it through SpringSecurity.
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Spring LDAP
Bundle-Vendor: SpringSource
Bundle-Version: 1.3.0.RELEASE
Bundle-SymbolicName: thirdparty.org.springframework.ldap
Import-Template: com.sun.jndi.ldap;version="0";resolution:=optional,
 org.apache.commons.lang.*;version="[2.3.0, 3.0.0)",
 org.apache.commons.logging;version="[1.0.4, 2.0.0)",
 org.apache.commons.pool.*;version="[1.3.0, 2.0.0)";resolution:="optional",
 org.springframework.*;version="${spring.version.range}"
Implementation-Title: Spring LDAP Core
Implementation-Version: 1.3.0.RELEASE
Spring-LDAP-Version: 1.3.0.RELEASE
Implementation-Vendor-Id: org.springframework.ldap


Regards,
Dmitry


Previous Topic:Virgo and Remote Services
Next Topic:Classloader Exception during EntityManager setup
Goto Forum:
  


Current Time: Tue Jul 01 18:02:54 EDT 2025

Powered by FUDForum. Page generated in 0.03340 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top