See:
http://www.springsource.com/beta/applicationplatform/comments.php?DiscussionID=53&page=1#Item_0
If I inject ServiceReference and BundleContext into a bean, and try to resolve it to a service interface at runtime using something like:
EchoService test = (EchoService) bundleContext.getService(serviceReference);
- it fails with the following error:
java.lang.ClassCastException: org.springframework.osgi.service.importer.support.ServiceReferenceDelegate
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.getService(BundleContextImpl.java:890)
at b3.impl.ClientServiceImpl.getEchoService(ClientServiceImpl.java:33)
at b3.impl.ClientServiceImpl$1.run(ClientServiceImpl.java:23)
The problem is in the org.eclipse.osgi codebase, where it assumes that the incoming object will be their custom implementation..
class BundleContextImpl:
public Object getService(org.osgi.framework.ServiceReference reference) {
...
ServiceRegistrationImpl registration = ((ServiceReferenceImpl) reference).registration;
...
}
So it seems it is NOT fixed!