Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
scr-1.6.0
-
None
Description
Consider this situation:
- Felix SCR 1.6
Import-Package: org.osgi.service.cm;version=[1.2,2.0);resolution:=optional - OSGi Enterprise R5 API bundle
Export-Package: org.osgi.service.cm;version=1.5 - Felix Configuration Admin 1.4.0
Export-Package: org.osgi.service.cm;version=1.4
Import-Package: org.osgi.service.cm;version=[1.4,1.5) - Component Bundle
Import-Package: org.osgi.service.cm;version=[1.4,1.5)
A component from the "Component Bundle" is registered and SCR happily starts creating it. SCR uses the Component Bundle's context to get the Configuration Admin serivce. Since the Component Bundle is wired tothe Felix Configuration Admin bundle it has an appropriate service implementation and the reference can be returned.
SCR then uses the Component Bundle's BundleContext to get the service. This succeeds.
Now SCR tries to cast the service Object to a ConfigurationAdmin object. But since the SCR bundle itself is wired to another API (the Enterprise one), the ConfugurationAdmin interface class objects are not the same and the cast fails.
Consequently, since this is not expected (but should be in this case), component creation fails.
The returned service should be checked, whether it can be cast to prevent this kind of failure.