Hi David, I'm not sure whether I fully understand or not, can you please clarify and describe with more details the circular dependency involved in this problem ?
As far as I understand what you are describing: - C is immediate, enabled, and has two required references on both A, B. - A is enabled and activating. And from it's activate method, A manually registers B (using bundleContext.registerService). Then, where is the dependency cycle ? C -> A, B but are A and/or B also depending on C ? thanks; /Pierre On Fri, Nov 1, 2013 at 7:53 AM, David Jencks <[email protected]> wrote: > After some investigation offline we determined that there was effectively > a circular dependency that was sometimes preventing some of the services > from activating immediately. Abstracting slightly… > component/service A registered service B in its activate method. Immediate > component C has mandatory dependencies on A and B. If C is enabled before > A, then A's activation will result in a problem as B will be registered > while the thread is still in A's activate method, so the component instance > cannot be returned from a getService call. Sometimes this circle is > detected by the service registry and sometimes by the DS circular > dependency detector. > > One solution is to register B in a separate thread started from A's > activate method. > > In general, this illustrates that registering services from within DS > lifecycle methods is apt to cause locking problems and should be avoided if > at all possible. > > thanks > david jencks > > On Oct 30, 2013, at 3:10 PM, Dave Smith <[email protected]> wrote: > > > Never see it. I will send you a copy of the full log off list. The only > > other interesting thing is the Activate method in ServiceRunner does > > register 3 other services that will be injected in components. > > > > Dave Smith > > Candata Ltd. > > 416-493-9020x2413 > > Direct: 416-855-2413 > > > > > > On Wed, Oct 30, 2013 at 5:52 PM, David Jencks <[email protected] > >wrote: > > > >> Does the activate method on ServiceRunnerImpl return? there should be a > >> log entry from > >> > >> logger.log( LogService.LOG_DEBUG, "invoked {0}: {1}: > >> parameters {2}", new Object[] > >> { getMethodNamePrefix(), getMethodName(), > >> Arrays.asList( params ) }, null ); > >> > >> Are there really no log statements between "found bind method" and > "could > >> not get service"? > >> > >> thanks > >> david jencks > >> > >> > >> On Oct 30, 2013, at 2:03 PM, Dave Smith <[email protected]> wrote: > >> > >>> OK. So I managed to pull the Snapshot from last night. Same problem. > >>> > >>> So here is where it registers > >>> > >>> 2013-10-30 04:34:15 4 > >>> [com.candata.core.server.impl.ServiceConfigurationImpl(220)] dm > >>> KeyValueDAO tracking 5 SingleStatic added > >>> {com.candata.util.common.services.KeyValueDAO}= > >>> {component.name=com.candata.util.server.impl.KeyValueDAOImpl, > >>> component.id=39, service.exported.interfaces=*, service.id=130} > >>> (enter) com.candata.core.server_1.0.0 [141] null null > >>> 2013-10-30 04:34:15 4 > >>> [com.candata.core.server.impl.ServiceConfigurationImpl(220)] > >>> ActivateInternal com.candata.core.server_1.0.0 [141] null null > >>> 2013-10-30 04:34:15 4 > >>> [com.candata.core.server.impl.ServiceConfigurationImpl(220)] > >>> Activating component from state 4 com.candata.core.server_1.0.0 [141] > >>> null null > >>> 2013-10-30 04:34:15 4 > >>> [com.candata.core.server.impl.ServiceConfigurationImpl(220)] > >>> registration change queue [registered] com.candata.core.server_1.0.0 > >>> [141] null null > >>> 2013-10-30 04:34:15 3 ServiceEvent REGISTERED > >>> com.candata.core.server_1.0.0 [141] > >>> {com.candata.core.server.services.ServiceConfiguration}= > >>> {component.name=com.candata.core.server.impl.ServiceConfigurationImpl, > >>> component.id=220, service.id=133} null > >>> > >>> > >>> > >>> And when it is injecting the references ... > >>> > >>> > >>> 2013-10-30 04:34:15 4 > >>> [com.candata.core.server.impl.ServiceConfigurationImpl(220)] Declared > >>> Method > >> > com.candata.core.server.impl.ServiceConfigurationImpl.setRunAsService([interface > >>> org.osgi.framework.ServiceReference]) not found > >>> com.candata.core.server_1.0.0 [141] null null > >>> 2013-10-30 04:34:15 4 > >>> [com.candata.core.server.impl.ServiceConfigurationImpl(220)] > >>> getParameterClass: Looking for interface class > >>> com.candata.core.server.services.RunAsService through loader of > >>> com.candata.core.server.impl.ServiceConfigurationImpl > >>> com.candata.core.server_1.0.0 [141] null null > >>> 2013-10-30 04:34:15 4 > >>> [com.candata.core.server.impl.ServiceConfigurationImpl(220)] > >>> getParameterClass: Found class > >>> com.candata.core.server.services.RunAsService > >>> com.candata.core.server_1.0.0 [141] null null > >>> 2013-10-30 04:34:15 4 > >>> [com.candata.core.server.impl.ServiceConfigurationImpl(220)] > >>> doFindMethod: No method taking ServiceReference found, checking method > >>> taking com.candata.core.server.services.RunAsService > >>> com.candata.core.server_1.0.0 [141] null null > >>> 2013-10-30 04:34:15 4 > >>> [com.candata.core.server.impl.ServiceConfigurationImpl(220)] Found > >>> bind method: protected void > >>> > >> > com.candata.core.server.impl.ServiceConfigurationImpl.setRunAsService(com.candata.core.server.services.RunAsService) > >>> com.candata.core.server_1.0.0 [141] null null > >>> 2013-10-30 04:34:15 2 > >>> [com.candata.core.server.impl.ServiceConfigurationImpl(220)] Could not > >>> get service from ref {com.candata.core.server.services.ServiceRunner, > >>> com.candata.core.server.services.RunAsService}={component.name > >> =com.candata.core.server.impl.ServiceRunnerImpl, > >>> component.id=223, service.id=92} com.candata.core.server_1.0.0 [141] > >>> null null > >>> 2013-10-30 04:34:15 3 FrameworkEvent WARNING > >>> com.candata.core.server_1.0.0 [141] null null > >>> 2013-10-30 04:34:15 4 > >>> [com.candata.core.server.impl.ServiceConfigurationImpl(220)] > >>> Deactivating dependency managers com.candata.core.server_1.0.0 [141] > >>> null null > >>> > >>> The only different thing about the RunAsService is that one impl is > >>> registered as more than service .. > >>> > >>> Here is the registration above > >>> 2013-10-30 04:34:14 3 ServiceEvent REGISTERED > >>> com.candata.core.server_1.0.0 [141] > >>> {com.candata.core.server.services.ServiceRunner, > >>> com.candata.core.server.services.RunAsService}= > >>> {component.name=com.candata.core.server.impl.ServiceRunnerImpl, > >>> component.id=223, service.id=92} null > >>> > >>> and the activate > >>> 013-10-30 04:34:14 4 > >>> [com.candata.core.server.impl.ServiceRunnerImpl(223)] Found activate > >>> method: protected void > >>> > >> > com.candata.core.server.impl.ServiceRunnerImpl.activate(org.osgi.framework.BundleContext) > >>> throws java.lang.Exception com.candata.core.server_1.0.0 [141] null > >>> null > >>> 2013-10-30 04:34:14 4 > >>> [com.candata.core.server.impl.ServiceRunnerImpl(223)] invoking > >>> activate: activate com.candata.core.server_1.0.0 [141] null null > >>> > >>> > >>> Let me know if you need any more info , debugging code etc ... > >>> > >>> > >>> > >>> > >>> On Wed, Oct 30, 2013 at 1:09 PM, David Jencks <[email protected] > >>> wrote: > >>> > >>>> There's another release candidate out that you could try, see the vote > >>>> email. > >>>> > >>>> I don't commit if I have test failures, and I've never seen the > problem > >>>> you show below. I suspect a maven issue. > >>>> > >>>> In the future please try to include enough information so that someone > >> who > >>>> is not already having the exact same problem you are can figure out > what > >>>> you are doing. It's pretty safe to assume that the code in svn works > >> well > >>>> for the developers so they probably don't know how to reproduce a > >> problem > >>>> you see. > >>>> > >>>> thanks > >>>> david jencks > >>>> > >>>> On Oct 30, 2013, at 6:32 AM, Dave Smith <[email protected]> > wrote: > >>>> > >>>>> Now the test cases are failing .. > >>>>> > >>>>> FYI: > >>>>> > >>>>> [INFO] --- org.apache.aries.versioning.plugin:0.1.0:version-check > >>>>> (default-verify) @ org.apache.felix.scr --- > >>>>> [WARNING] Error injecting: > >>>>> org.apache.aries.versioning.mojo.VersionCheckerMojo > >>>>> java.lang.NoClassDefFoundError: > >>>>> org/sonatype/aether/resolution/ArtifactResolutionException > >>>>> > >>>>> Caused by: java.lang.ClassNotFoundException: > >>>>> org.sonatype.aether.resolution.ArtifactResolutionException > >>>>> at > >>>>> > >>>> > >> > org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50) > >>>>> at > >>>>> > >>>> > >> > org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259) > >>>>> at > >>>>> > >>>> > >> > org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:242) > >>>>> at > >>>>> > >>>> > >> > org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227) > >>>>> > >>>>> > >>>>> Looks like you are still a bit raw. Give me a heads up when you are a > >>>>> little closer and I will test here..... > >>>>> > >>>>> > >>>>> > >>>>> On Tue, Oct 29, 2013 at 7:39 PM, David Jencks < > [email protected] > >>>>> wrote: > >>>>> > >>>>>> Ah, I'm sort of in the middle of a release. > >>>>>> > >>>>>> You can alter the scr pom locally to point to 1.5.0-SNAPSHOT, get > the > >>>> 1.4 > >>>>>> release candidate from > >>>>>> > >> https://repository.apache.org/content/repositories/orgapachefelix-024/, > >>>>>> or build the 1.4 release candidate from > >>>>>> > >>>>>> > >>>>>> > >>>> > >> > https://svn.apache.org/repos/asf/felix/releases/org.apache.felix.utils-1.4.0 > >>>>>> > >>>>>> hope this helps > >>>>>> david jencks > >>>>>> > >>>>>> On Oct 29, 2013, at 11:36 AM, Dave Smith <[email protected]> > >>>> wrote: > >>>>>> > >>>>>>> [INFO] Building Apache Felix Declarative Services 1.7-SNAPSHOT > >>>>>>> [INFO] > >>>>>>> > >>>> > ------------------------------------------------------------------------ > >>>>>>> [WARNING] The POM for > >> org.apache.felix:org.apache.felix.utils:jar:1.4.0 > >>>>>> is > >>>>>>> missing, no dependency information available > >>>>>>> [INFO] > >>>>>>> > >>>> > ------------------------------------------------------------------------ > >>>>>>> > >>>>>>> [ERROR] Failed to execute goal on project org.apache.felix.scr: > Could > >>>> not > >>>>>>> resolve dependencies for project > >>>>>>> org.apache.felix:org.apache.felix.scr:bundle:1.7-SNAPSHOT: Failure > to > >>>>>> find > >>>>>>> org.apache.felix:org.apache.felix.utils:jar:1.4.0 in > >>>>>>> http://repo.maven.apache.org/maven2 was cached in the local > >>>> repository, > >>>>>>> resolution will not be reattempted until the update interval of > >> central > >>>>>> has > >>>>>>> elapsed or updates are forced -> [Help 1] > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> On Tue, Oct 29, 2013 at 2:04 PM, David Jencks < > >> [email protected] > >>>>>>> wrote: > >>>>>>> > >>>>>>>> Well, the 1.7-SNAPSHOT in the apache nexus snapshot repo is up to > >>>> date. > >>>>>>>> > >>>>>>>> I run mvn clean install in scr with no problems, using maven > 3.0.4. > >>>>>> What > >>>>>>>> problems are you seeing? > >>>>>>>> > >>>>>>>> thanks > >>>>>>>> david jencks > >>>>>>>> > >>>>>>>> On Oct 29, 2013, at 10:54 AM, Dave Smith <[email protected]> > >>>>>> wrote: > >>>>>>>> > >>>>>>>>> I tried following the instructions but It seems the scr is not > >> built > >>>> in > >>>>>>>> and > >>>>>>>>> when I try and run mvn in the scr dir that does not work either. > >>>>>>>>> > >>>>>>>>> I am following ... > >>>>>>>>> > >>>>>>>>> http://felix.apache.org/site/building-felix.html > >>>>>>>>> > >>>>>>>>> instructuctions > >>>>>>>>> > >>>>>>>>> Dave Smith > >>>>>>>>> Candata Ltd. > >>>>>>>>> 416-493-9020x2413 > >>>>>>>>> Direct: 416-855-2413 > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> On Tue, Oct 29, 2013 at 11:41 AM, Dave Smith < > >> [email protected] > >>>>> > >>>>>>>> wrote: > >>>>>>>>> > >>>>>>>>>> Latest 1.6.2. I will grab the snapshot and report back... > >>>>>>>>>> > >>>>>>>>>> Dave Smith > >>>>>>>>>> Candata Ltd. > >>>>>>>>>> 416-493-9020x2413 > >>>>>>>>>> Direct: 416-855-2413 > >>>>>>>>>> > >>>>>>>>>> > >>>>>>>>>> On Tue, Oct 29, 2013 at 11:38 AM, David Jencks < > >>>>>> [email protected] > >>>>>>>>> wrote: > >>>>>>>>>> > >>>>>>>>>>> Not telling us the exact version of the code you are using > makes > >> it > >>>>>>>>>>> pretty much impossible to think about investigating this. > >>>>>>>>>>> > >>>>>>>>>>> Please see if this is a problem with the current trunk code > which > >>>> you > >>>>>>>> can > >>>>>>>>>>> build yourself or use the 1.7-SNAPSHOT on the apache snapshot > >> repo. > >>>>>>>>>>> > >>>>>>>>>>> I'm working on a release and at this point we're finding and > >> fixing > >>>>>>>> bugs. > >>>>>>>>>>> When we've stopped finding bugs I'll release. > >>>>>>>>>>> > >>>>>>>>>>> thanks > >>>>>>>>>>> david jencks > >>>>>>>>>>> > >>>>>>>>>>> On Oct 29, 2013, at 8:15 AM, Dave Smith < > [email protected]> > >>>>>>>> wrote: > >>>>>>>>>>> > >>>>>>>>>>>> I posted a bug a few weeks back and the thought was a new > >> version > >>>> is > >>>>>>>>>>> coming > >>>>>>>>>>>> soon. Since it was more of an annoyance I decided to wait. I > am > >>>> now > >>>>>>>>>>> having > >>>>>>>>>>>> an intermittent problem with a service not getting activated. > >> Here > >>>>>> is > >>>>>>>> a > >>>>>>>>>>>> snippet from the log > >>>>>>>>>>>> > >>>>>>>>>>>> 2013-10-29 10:49:27 4 > >>>>>>>>>>>> [com.candata.core.server.impl.ServiceConfigurationImpl] > >>>>>>>>>>>> getParameterClass: Found class > >>>>>>>>>>>> com.candata.core.server.services.RunAsService > >>>>>>>>>>>> com.candata.core.server_1.0.0 [141] null null > >>>>>>>>>>>> 2013-10-29 10:49:27 4 > >>>>>>>>>>>> [com.candata.core.server.impl.ServiceConfigurationImpl] > >>>>>> doFindMethod: > >>>>>>>>>>>> No method taking ServiceReference found, checking method > taking > >>>>>>>>>>>> com.candata.core.server.services.RunAsService > >>>>>>>>>>>> com.candata.core.server_1.0.0 [141] null null > >>>>>>>>>>>> 2013-10-29 10:49:27 4 > >>>>>>>>>>>> [com.candata.core.server.impl.ServiceConfigurationImpl] Found > >> bind > >>>>>>>>>>>> method: protected void > >>>>>>>>>>>> > >>>>>>>>>>> > >>>>>>>> > >>>>>> > >>>> > >> > com.candata.core.server.impl.ServiceConfigurationImpl.setRunAsService(com.candata.core.server.services.RunAsService) > >>>>>>>>>>>> com.candata.core.server_1.0.0 [141] null null > >>>>>>>>>>>> 2013-10-29 10:49:27 4 > >>>>>> [com.candata.core.server.impl.ServiceRunnerImpl] > >>>>>>>>>>>> dependency map already present, do not collect dependencies > >>>>>>>>>>>> com.candata.core.server_1.0.0 [141] null null > >>>>>>>>>>>> 2013-10-29 10:49:27 4 > >>>>>> [com.candata.core.server.impl.ServiceRunnerImpl] > >>>>>>>>>>>> getService did not win collecting dependencies, try creating > >>>> object > >>>>>>>>>>>> anyway. com.candata.core.server_1.0.0 [141] null null > >>>>>>>>>>>> 2013-10-29 10:49:27 3 FrameworkEvent WARNING > >>>>>>>>>>>> com.candata.core.server_1.0.0 [141] null null > >>>>>>>>>>>> 2013-10-29 10:49:27 2 > >>>>>>>>>>>> [com.candata.core.server.impl.ServiceConfigurationImpl] Could > >> not > >>>>>> get > >>>>>>>>>>>> service from ref > >> {com.candata.core.server.services.ServiceRunner, > >>>>>>>>>>>> com.candata.core.server.services.RunAsService}={ > component.name > >>>>>>>>>>> =com.candata.core.server.impl.ServiceRunnerImpl, > >>>>>>>>>>>> component.id=233, service.id=91} > com.candata.core.server_1.0.0 > >>>>>> [141] > >>>>>>>>>>> null null > >>>>>>>>>>>> > >>>>>>>>>>>> If -> getService did not win collecting dependencies, try > >> creating > >>>>>>>>>>> object > >>>>>>>>>>>> anyway > >>>>>>>>>>>> > >>>>>>>>>>>> then the service never gets activated , if it wins then it > does. > >>>> I > >>>>>>>>>>>> can see by the logs that the service is registered with OSGI > >>>> farther > >>>>>>>>>>>> up > >>>>>>>>>>>> > >>>>>>>>>>>> > >>>>>>>>>>>> 2013-10-29 10:49:27 3 ServiceEvent REGISTERED > >>>>>>>>>>>> com.candata.core.server_1.0.0 [141] > >>>>>>>>>>>> {com.candata.core.server.services.ServiceRunner, > >>>>>>>>>>>> com.candata.core.server.services.RunAsService}={ > component.name > >>>>>>>>>>> =com.candata.core.server.impl.ServiceRunnerImpl, > >>>>>>>>>>>> component.id=233, service.id=91} null > >>>>>>>>>>>> > >>>>>>>>>>>> Is the next release soon? Or has this code not changed and > could > >>>> be > >>>>>>>>>>>> considered a bug > >>>>>>>>>>> > >>>>>>>>>>> > >>>>>>>>>>> > >>>> --------------------------------------------------------------------- > >>>>>>>>>>> To unsubscribe, e-mail: [email protected] > >>>>>>>>>>> For additional commands, e-mail: [email protected] > >>>>>>>>>>> > >>>>>>>>>>> > >>>>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> > >> --------------------------------------------------------------------- > >>>>>>>> To unsubscribe, e-mail: [email protected] > >>>>>>>> For additional commands, e-mail: [email protected] > >>>>>>>> > >>>>>>>> > >>>>>> > >>>>>> > >>>>>> > --------------------------------------------------------------------- > >>>>>> To unsubscribe, e-mail: [email protected] > >>>>>> For additional commands, e-mail: [email protected] > >>>>>> > >>>>>> > >>>> > >>>> > >>>> --------------------------------------------------------------------- > >>>> To unsubscribe, e-mail: [email protected] > >>>> For additional commands, e-mail: [email protected] > >>>> > >>>> > >> > >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >

