Declarative services component both satisfied and unsatisfied

3.5k Views Asked by At

I am developing an OSGI-based system which uses declarative services to define components. However, when running it from Eclipse, one of my components is not initialized. When I investigate the issue using simple console commands, I get the following output (with some small obfuscation):

osgi> component 51
    Component[
    name = com.e.location.view
    activate = activate
    deactivate = deactivate
    modified = 
    configuration-policy = optional
    factory = null
    autoenable = true
    immediate = false
    implementation = com.e.location.view.LocationViewContribution
    state = Unsatisfied
    properties = 
    serviceFactory = false
    serviceInterface = [com.e.model.ViewContribution]
    references = {
        Reference[name = SpecificationProvider, interface = com.e.SpecificationProvider, policy = static, cardinality = 1..1, target = null, bind = setSpecificationProvider, unbind = null]
    }
    located in bundle = com.e.location.view_1.0.0.SNAPSHOT [107]
]
Dynamic information :
  The component is satisfied
  All component references are satisfied
  Component configurations :
    Configuration properties:
      component.name = com.e.location.view
      component.id = 55
      objectClass = String[com.e.model.ViewContribution]
    Instances:

So the component has state = Unsatisfied, but the dynamic information states the component is satisfied and its component references are satisfied too.

Can anybody explain this? Why is my component not initialized?

UPDATE: Apparently, setting immedate="true" for the component fixes the initialization problem. The osgi command still has state = Unsatisfied though. Anybody know why?

2

There are 2 best solutions below

3
On

We had similar issues when:

  • The activate method of the component threw an exception (see the log)
  • The activate method of the component did not return (see a thread dump)
    • Infinite loop (or JVM enhanced recursion) in activate
    • Deadlock

If you are in equinox and did not install a bundle that forwards the LogEvents to the logfile/console, do not forget to check the configuration directory, where equinox puts log files for error messages.

5
On

Remember that the constructor of your component must not have arguments.

Also, force enabling using enabled="true" immediate="true" attributes in the <scr:component> tag.