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

David McIntyre commented on FELIX-2923:
---------------------------------------

I see the same problem with release 2.0.14 of Felix SCR.

 In its simplest form, I have three services:
* Service A is created by DS, and registers an instance of Service B in its 
activate method
* Service C is created by DS, and references instances of Service A and Service 
B.

Depending on the order that the services are created, this can fail. If A is 
created first, then C can be created and activated with no issue. However, if C 
is created first then it will initially not have its dependencies satisfied: 
when Service A is then created, its activate method is called, the dependencies 
of Service C will be satisfied and so it will attempt to bind its references in 
the same thread. This will fail because it will call 
{{org.apache.felix.scr.impl.ComponentRegistry.enterCreate(ServiceReference<T>)}}
 again with a reference to Service A.

Of course, this is rather artificial, but in practice we have examples such as 
a DataSourceService which depends on a DriverActivator which registers various 
database drivers in its activate method, and an EmbeddedDatabaseService which 
depends on one of those database drivers and also depends on the 
DataSourceService so that it can find all the data sources using that driver.

The problem seems to be that 
{{org.apache.felix.scr.impl.manager.DependencyManager.AbstractCustomizer.isSatisfied()}}
 depends only on whether the service tracker passes the cardinality check, and 
not on whether the services being tracked are actually active.

Since there is not actually a circular dependency, I don't see how this is 
behaving as required by the spec.

> Get a ServiceFactory.getService()  resulted in a cycle message when 
> registering a service inside a DS activation method
> -----------------------------------------------------------------------------------------------------------------------
>
>                 Key: FELIX-2923
>                 URL: https://issues.apache.org/jira/browse/FELIX-2923
>             Project: Felix
>          Issue Type: Bug
>          Components: Declarative Services (SCR)
>    Affects Versions:  scr-1.6.0
>            Reporter: David Humeniuk
>            Assignee: David Jencks
>            Priority: Major
>
> I've run into an issue with Felix SCR where I get the message:
> ServiceFactory.getService() resulted in a cycle
> The reason this appers to be occuring is because within an activation method 
> of a service component, call it ServiceAImpl (which provides ServiceA), the 
> component registers another service, call it ServiceB.
> I have another service component, call it ServiceCImpl, which depends on both 
> ServiceA and ServiceB. When ServiceAImpl registers ServiceB, ServiceCImpl is 
> attemted to be activated within the call to activate ServiceAImpl.  As part 
> of the activation, the ServiceCImpl binding methods are called (at least 
> attempted). When the binding method for ServiceA is attempted, the cycle is 
> detected and the component fails to initialize.
> I guess what doesn't make sense is why the SCR will activate ServiceCImpl 
> within the activation method of ServiceAImpl. I wouldn't think that 
> ServiceCImpl would be considered satisfied until after the activation method 
> has exited. Perhaps this is an issue of using declarative services while 
> still registering services directly with the framework?



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to