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

Andreas Lemmer commented on FELIX-6069:
---------------------------------------

I have found out that this problem is mainly caused by SCR using "bundle" 
dependencies. If Component1 in Bundle1 implements Interface1 in Bundle2 and 
Component2 in Bundle2 binds Interface1, this is already reported as circular 
reference because Bundle1 requires Bundle2 (correct because of the interface 
dependency) and in Felix SCR, Bundle2 "requires/wants" Bundle1 because it binds 
a service from it.

The only way to make this work without problems is to move the interface to a 
separate bundle.

Note that SCR often complains about circular references (often wrongly) and it 
seems to work most of the time, we have found that sometimes (0.1%-1%), it 
actually fails and doesn't start these components at all or doesn't bind the 
references!

> 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.10#820010)

Reply via email to