OSGi application subsystem is ACTIVE, but its components are not

200 views Asked by At

I have created an OSGi bundle (written in Kotlin) containing a very basic component, which I have annotated as @Component(immediate = true). This bundle behaves as expected using Felix 6.0.3.

@Component(immediate = true)
class Bongo @Activate constructor(
    @Reference(service = LoggerFactory::class)
    private val logger: Logger
) {
    init {
        System.err.println("-------------- BONGO!")
        logger.info("Started {}", this::class.java)
    }

    @Activate
    fun doIt() {
        throw InternalError("BOOM!")
    }
}

I then zip this bundle up (with some others) and feed it into Apache Aries as a trivial application subsystem. I haven't created an explicit SUBSYSTEM.MF here because the default values appear to be what I want. Aries installs and starts my subsystem, and then reports that it is ACTIVE. I have even confirmed that a BundleActivator has been invoked correctly. However, I see no evidence that my @Component has been started. It looks like SCR has ignored it, which seems odd because I would have thought that I'd need SCR to run an application subsystem. (I have heard that Declarative Services have replaced BundleActivator...)

I have scoured the OSGi documentation and found no mention of needing to do anything with an OSGi subsystem other than "start" it, so I am baffled at how to proceed from here. Can anyone suggest anything I might have missed please?

For reference, these are the Felix / Aries bundles from my bndrun file:

    org.apache.aries.subsystem.api;version='[2.0.10,2.0.11)',\
    org.apache.aries.subsystem.core;version='[2.0.10,2.0.11)',\
    org.apache.aries.util;version='[1.1.1,1.1.2)',\
    org.apache.felix.bundlerepository;version='[2.0.10,2.0.11)',\
    org.apache.felix.configadmin;version='[1.9.18,1.9.19)',\
    org.apache.felix.coordinator;version='[1.0.2,1.0.3)',\
    org.apache.felix.log;version='[1.2.2,1.2.3)',\
    org.apache.felix.logback;version='[1.0.2,1.0.3)',\
    org.apache.felix.scr;version='[2.1.20,2.1.21)',\
    org.eclipse.equinox.region;version='[1.2.101,1.2.102)',\

Thanks, Chris

1

There are 1 answers

0
Chris Rankin On BEST ANSWER

Thanks to Neil Bartlett, I now understand that each application subsystem would need to contain its own SCR bundle before Felix could find its components. Specifically:

SCR is not just a dependency, it scans bundles for the Service-Component header. The Declarative Services specification does not describe any way for SCR to discover bundles inside a subsystem of the running framework, therefore your bundles will be invisible to it.

David Jencks has also elaborated specifically about the Felix SCR:

IIRC you need to configure SCR with the ds.global.extender flag set to true, then the single SCR will find components everywhere.