Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Spring LDAP and exporting the service
Spring LDAP and exporting the service [message #640211] Fri, 19 November 2010 15:33 Go to next message
Onur G is currently offline Onur GFriend
Messages: 1
Registered: November 2010
Junior Member
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

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 05:18 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
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 14:32 Go to previous message
Dmitry Sklyut is currently offline Dmitry SklyutFriend
Messages: 279
Registered: January 2010
Senior Member

Did you end up re-bundling spring-ldap 1.3.0? If you got that package from 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
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",
Implementation-Title: Spring LDAP Core
Implementation-Version: 1.3.0.RELEASE
Spring-LDAP-Version: 1.3.0.RELEASE
Implementation-Vendor-Id: org.springframework.ldap


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

Current Time: Sat Mar 06 12:19:22 GMT 2021

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

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

Back to the top