[ 
https://issues.apache.org/jira/browse/FELIX-6069?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17467775#comment-17467775
 ] 

David Jencks commented on FELIX-6069:
-------------------------------------

I don't think there's any practical way to detect this situation.  You 
shouldn't use circular references, they are never going to be very reliable.

> SCR detects cyclic dependency for dynamically bound service
> -----------------------------------------------------------
>
>                 Key: FELIX-6069
>                 URL: https://issues.apache.org/jira/browse/FELIX-6069
>             Project: Felix
>          Issue Type: Bug
>          Components: Declarative Services (SCR)
>    Affects Versions: scr-2.1.14
>            Reporter: Andreas Lemmer
>            Priority: Major
>              Labels: cyclic, scr
>
> Problem case: A bundle with two components: Component1 binds Component2 
> statically, Component2 binds Component1 dynamically. Both components have 
> immediate=true (but changing that also doesn't help).
> When starting the bundle, there is (nearly always) a Framework error message 
> from SCR:
> {{ERROR [org.apache.felix.scr] bundle org.apache.felix.scr:2.1.14 
> (12)Circular reference detected trying to get service [Component1]}}
> {{stack of references: ServiceReference: [Component1]}}
> {{ServiceReference: [Component2]}}
> {{java.lang.Exception: stack trace}}
> {{at 
> org.apache.felix.scr.impl.ComponentRegistry.enterCreate(ComponentRegistry.java:485)}}
> {{at 
> org.apache.felix.scr.impl.BundleComponentActivator.enterCreate(BundleComponentActivator.java:735)}}
> {{at 
> org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:882)}}
> SCR tries it again a few milliseconds later *which works*.
> The real problem here is the error logging indicating that something is not 
> working. This is very disturbing, because the behavior changes from time to 
> time which makes it very hard to see if something is really wrong or if it's 
> just a temporary problem.
> In my opinion, SCR should first start Component2 without Component1, then 
> start Component1 and then bind Component1 to Component2.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to