felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Felix Meschberger (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (FELIX-3723) ClassCastException on ConfigurationAdmin service creating components
Date Fri, 19 Oct 2012 13:24:12 GMT

     [ https://issues.apache.org/jira/browse/FELIX-3723?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

Felix Meschberger resolved FELIX-3723.

    Resolution: Fixed

Fixed Rev. 1400089

The ConfigurationAdmin service retrieved with the component's bundle context is checked against
the ConfigurationAdmin API to which the DS bundle is wired. If it is not the same a WARN message
is logged. Otherwise the component is configured as expected.
> ClassCastException on ConfigurationAdmin service creating components 
> ---------------------------------------------------------------------
>                 Key: FELIX-3723
>                 URL: https://issues.apache.org/jira/browse/FELIX-3723
>             Project: Felix
>          Issue Type: Bug
>          Components: Declarative Services (SCR)
>    Affects Versions:  scr-1.6.0
>            Reporter: Felix Meschberger
>            Assignee: Felix Meschberger
>             Fix For: scr-1.6.2
> 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
> The returned service should be checked, whether it can be cast to prevent this kind of

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

View raw message