1

I have an unsatisfied OSGI component, which seems to tell me that it is satisfied...

If I type ls the result is the following:

26  Active org.eclipse.kura.watchdog.WatchdogService org.eclipse.kura.linux.watchdog(bid=63)
82  Active com.company.product.dependencybucketimpl.DependencyBucketImpl            com.company.product.dependencybucketimpl(bid=122)
83  Unsatisfied com.company.product.statemachineXXXXimpl.StateMachineXXXXImpl com.company.product.statemachineXXXXimpl(bid=123)

There are several other bundles but these are the relevant ones.

When I try to look at the Unsatisfied bundle specifically, it seems that the two bundles which are referenced have been activated successfully.

osgi> ls -c 123
Components in bundle com.company.product.statemachineXXXXimpl:
ID  Component details
83  Component[
    name = com.company.product.statemachineXXXXimpl.StateMachineXXXXImpl
    activate = activate
    deactivate = deactivate
    modified = modified
    configuration-policy = optional
    factory = null
    autoenable = true
    immediate = true
    implementation = com.company.product.statemachineXXXXimpl.StateMachineXXXXImpl
    state = Unsatisfied
    properties = {service.pid=com.company.product.statemachineXXXXimpl.StateMachineXXXXImpl}
    serviceFactory = false
    serviceInterface = [com.company.product.common.PayloadReadyNotifier, com.company.product.common.StateMachineXXXX]
    references = {
        Reference[name = WatchdogService, interface = org.eclipse.kura.watchdog.WatchdogService, policy = static, cardinality = 1..1, target = null, bind = setWatchdogService, unbind = unsetWatchdogService]
        Reference[name = DependencyBucket, interface = com.company.product.common.DependencyBucket, policy = static, cardinality = 1..1, target = null, bind = setDependencyBucket, unbind = unsetDependencyBucket]
    }
    located in bundle = com.company.product.statemachineXXXXimpl_1.0.0.dev [123]
]
Dynamic information :
  The component is satisfied
  All component references are satisfied
  Component configurations :
    Configuration properties:
      logStateMachineTransitions = true
      objectClass = String[com.company.product.common.PayloadReadyNotifier,com.company.product.common.StateMachineXXXX]
      kura.service.pid = com.company.product.statemachineXXXXimpl.StateMachineXXXXImpl
      service.pid = com.company.product.statemachineXXXXimpl.StateMachineXXXXImpl
      systemIdleTimeout = 600
      ChargerDischargeTimeout = 300
      component.name = com.company.product.statemachineXXXXimpl.StateMachineXXXXImpl
      component.id = 178
    Instances:

Here is the .xml in the definition for the bundle in question:

<?xml version="1.0" encoding="UTF-8"?>

<component xmlns="http://www.osgi.org/xmlns/scr/v1.1.0"
           name="com.company.product.statemachineXXXXimpl.StateMachineXXXXImpl"
           activate="activate"
           configuration-policy="optional"
           deactivate="deactivate"
           enabled="true"
           immediate="true"
           modified="modified">

    <implementation class="com.company.product.statemachineXXXXimpl.StateMachineXXXXImpl"/>

    <property name="service.pid"
              type="String"
              value="com.company.product.statemachineXXXXimpl.StateMachineXXXXImpl"/>

    <reference name="WatchdogService"
               bind="setWatchdogService"
               unbind="unsetWatchdogService"
               interface="org.eclipse.kura.watchdog.WatchdogService"
               cardinality="1..1"
               policy="static"/>

    <reference name="DependencyBucket"
               bind="setDependencyBucket"
               unbind="unsetDependencyBucket"
               interface="com.company.product.common.DependencyBucket"
               cardinality="1..1"
               policy="static"/>

    <service>
        <provide interface="com.company.product.common.PayloadReadyNotifier"/>
        <provide interface="com.company.product.common.StateMachineXXXX"/>
        <!--<provide interface="com.company.product.common.ComponentStatusProvider"/>-->
    </service>

</component>

In other bundles which are activated successfully, there is an object listed under "Instances:" But this is not the case here.

I am confused as to why if "The component is satisfied" and "All component references are satisfied" why the ls command shows that the component is "Unsatisfied." Wondering how I might fix this! Any help would be appreciated!

EDIT: Looked in /var/log/kura-console.log and saw this:

ENTRY org.eclipse.equinox.metatype 4 0 2018-05-02 21:03:45.009
!MESSAGE DataParser.finished() Missing element AD (Reference ID = com.company.product.dependencybucketimpl.DependencyBucketImpl.

!ENTRY org.eclipse.equinox.metatype 4 0 2018-05-02 21:03:45.018
!MESSAGE DataParser.finished() Object Class Definition ID not found com.company.product.dependencybucketimpl.DependencyBucketImpl.

!ENTRY com.company.product.dependencybucketimpl 4 0 2018-05-02 21:03:47.230
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.ServiceException: org.eclipse.equinox.internal.ds.ServiceReg.getService() returned a service object that is not an instance of the service class com.company.product.common.PayloadReadyNotifier
  at org.eclipse.osgi.internal.serviceregistry.ServiceUse.getService(ServiceUse.java:174)
  at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:468)
  at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.getService(ServiceRegistry.java:467)
  at org.eclipse.osgi.framework.internal.core.BundleContextImpl.getService(BundleContextImpl.java:594)
  at org.eclipse.equinox.internal.ds.InstanceProcess.getService(InstanceProcess.java:730)
  at org.eclipse.equinox.internal.ds.model.ComponentReference.bind(ComponentReference.java:347)
  at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.bindReference(ServiceComponentProp.java:446)
  at org.eclipse.equinox.internal.ds.InstanceProcess.dynamicBind(InstanceProcess.java:416)
  at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:334)
  at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
  at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
  at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
  at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
  at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
  at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
  at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry$1.run(ServiceRegistry.java:775)
  at java.security.AccessController.doPrivileged(Native Method)
  at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:773)
  at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
  at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
  at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
  at org.eclipse.equinox.internal.ds.InstanceProcess.registerService(InstanceProcess.java:536)
  at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:213)
  at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
  at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
  at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
  at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
  at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
  at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
  at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
  at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry$1.run(ServiceRegistry.java:775)
  at java.security.AccessController.doPrivileged(Native Method)
  at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:773)
  at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
  at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
  at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
  at org.eclipse.equinox.internal.ds.InstanceProcess.registerService(InstanceProcess.java:536)
  at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:213)
  at org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473)
  at org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217)
  at org.eclipse.equinox.internal.ds.SCRManager.performWork(SCRManager.java:816)
  at org.eclipse.equinox.internal.ds.SCRManager$QueuedJob.dispatch(SCRManager.java:783)
  at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:89)
  at org.eclipse.equinox.internal.util.impl.tpt.threadpool.Executor.run(Executor.java:70)

The "Object Class Definition ID not found" bit here looks promising... I have double and triple checked case for the name of the package.

Followed by:

!ENTRY com.company.product.statemachineXXXXimpl 2 0 2018-05-02 21:03:47.284
!MESSAGE [SCR] Could not get the service object relevant to the reference. One possible reason is a circularity problem. Another possible reason is that BundleContext.getService() returns null.
  Details:
  Problematic reference = Reference[name = DependencyBucket, interface = com.company.product.common.DependencyBucket, policy = static, cardinality = 1..1, target = null, bind = setDependencyBucket, unbind = unsetDependencyBucket]
  of service component = com.company.product.statemachineXXXXimpl.StateMachineXXXXImpl
  component implementation class = com.company.product.statemachineXXXXimpl.StateMachineXXXXImpl
  located in bundle with symbolic name = com.company.product.statemachineXXXXimpl
  bundle location = osgi-dp:com.company.product.statemachineXXXXimpl

!ENTRY com.company.product.statemachineXXXXimpl 2 0 2018-05-02 21:03:47.286
!MESSAGE [SCR] ComponentReference.bind(): bind method 'setDependencyBucket' is not found or it is not accessible!
  Details:
  Problematic reference = Reference[name = DependencyBucket, interface = com.company.product.common.DependencyBucket, policy = static, cardinality = 1..1, target = null, bind = setDependencyBucket, unbind = unsetDependencyBucket]
  of service component = com.company.product.statemachineXXXXimpl.StateMachineXXXXImpl
  component implementation class = com.company.product.statemachineXXXXimpl.StateMachineXXXXImpl
  located in bundle with symbolic name = com.company.product.statemachineXXXXimpl
  bundle location = osgi-dp:com.company.product.statemachineXXXXimpl

!ENTRY org.eclipse.equinox.ds 2 0 2018-05-02 21:03:47.291
!MESSAGE Could not bind a reference of component com.company.product.statemachineXXXXimpl.StateMachineXXXXImpl. The reference is: Reference[name = DependencyBucket, interface = com.company.product.common.DependencyBucket, policy = static, cardinality = 1..1, target = null, bind = setDependencyBucket, unbind = unsetDependencyBucket]

!ENTRY org.eclipse.equinox.ds 4 0 2018-05-02 21:03:47.352
!MESSAGE The component was not built because some of its references could not be bound. The component is Component[
  name = com.company.product.statemachineXXXXimpl.StateMachineXXXXImpl
  activate = activate
  deactivate = deactivate
  modified = modified
  configuration-policy = optional
  factory = null
  autoenable = true
  immediate = true
  implementation = com.company.product.statemachineXXXXimpl.StateMachineXXXXImpl
  state = Unsatisfied
  properties = {service.pid=com.company.product.statemachineXXXXimpl.StateMachineXXXXImpl}
  serviceFactory = false
  serviceInterface = [com.company.product.common.StateMachineXXXX]
  references = {
    Reference[name = WatchdogService, interface = org.eclipse.kura.watchdog.WatchdogService, policy = static, cardinality = 1..1, target = null, bind = setWatchdogService, unbind = unsetWatchdogService]
    Reference[name = DependencyBucket, interface = com.company.product.common.DependencyBucket, policy = static, cardinality = 1..1, target = null, bind = setDependencyBucket, unbind = unsetDependencyBucket]
  }
  located in bundle = com.company.product.statemachineXXXXimpl_1.0.0.dev [92]
]

I am quite sure that the setDependencyBucket is implemented in the state machine implementation file, so I think the real snag is probably not in this block.

After removing the dependency on PayloadReadyNotifier some errors seem to be resolved. Remaining still are:

!ENTRY org.eclipse.equinox.metatype 4 0 2018-05-02 21:19:12.360
!MESSAGE DataParser.finished() Missing element AD (Reference ID = com.freewire.mobi.dependencybucketimpl.DependencyBucketImpl.

!ENTRY org.eclipse.equinox.metatype 4 0 2018-05-02 21:19:12.364
!MESSAGE DataParser.finished() Object Class Definition ID not found com.freewire.mobi.dependencybucketimpl.DependencyBucketImpl.

Feels close! Is this something wrong with the .xml perhaps?

EDIT #2: Added Component xml:

<?xml version="1.0" encoding="UTF-8"?>

<component xmlns="http://www.osgi.org/xmlns/scr/v1.1.0"
           name="com.company.product.dependencybucketimpl.DependencyBucketImpl"
           activate="activate"
           configuration-policy="optional"
           deactivate="deactivate"
           enabled="true"
           immediate="true"
           modified="modified">

    <implementation class="com.company.product.dependencybucketimpl.DependencyBucketImpl"/>

    <property name="service.pid"
              type="String"
              value="com.company.product.dependencybucketimpl.DependencyBucketImpl"/>

    <reference name="InverterManager"
               bind="setInverterManager"
               unbind="unsetInverterManager"
               interface="com.company.product.common.InverterManager"
               cardinality="1..1"
               policy="static"/>

    <reference name="BmsManager"
               bind="setBmsManager"
               unbind="unsetBmsManager"
               interface="com.company.product.common.BmsManager"
               cardinality="1..1"
               policy="static"/>

    <reference name="CanConnector"
               bind="setCanConnector"
               unbind="unsetCanConnector"
               interface="com.company.product.common.CanConnector"
               cardinality="1..1"
               policy="static"/>

    <reference name="ModbusManagerV1P2"
               bind="setModbusManagerV1P2"
               unbind="unsetModbusManagerV1P2"
               interface="com.company.product.common.ModbusManagerV1P2"
               cardinality="1..1"
               policy="static"/>

    <reference name="ModbusConnector"
               bind="setModbusConnector"
               unbind="unsetModbusConnector"
               interface="com.company.product.common.ModbusConnector"
               cardinality="1..1"
               policy="static"/>

    <reference name="GpioManagerL2Gen"
               bind="setGpioManagerL2Gen"
               unbind="unsetGpioManagerL2Gen"
               interface="com.company.product.common.GpioManagerL2Gen"
               cardinality="1..1"
               policy="static"/>

    <reference name="UnitConfiguration"
               bind="setUnitConfiguration"
               unbind="unsetUnitConfiguration"
               interface="com.company.product.common.UnitConfiguration"
               cardinality="1..1"
               policy="static"/>

    <service>
        <!--<provide interface="com.company.product.common.PayloadReadyNotifier"/>-->
        <provide interface="com.company.product.common.DependencyBucket"/>
        <!--<provide interface="com.company.product.common.ComponentStatusProvider"/>-->
    </service>

</component>

And the metatype:

<?xml version="1.0" encoding="UTF-8"?>

<MetaData xmlns="http://www.osgi.org/xmlns/metatype/v1.2.0"
          localization="en_us">

    <OCD id="com.company.product.dependencybucketimpl.DependencyBucketImpl"
         name="DependencyBucketImpl"
         description="">

    </OCD>

    <Designate pid="com.company.product.dependencybucketimpl.DependencyBucketImpl">
        <Object ocdref="com.company.product.dependencybucketimpl.DependencyBucketImpl"/>
    </Designate>
</MetaData>
  • This can sometimes happen if a runtime error is thrown when the bundle is starting. Can you try stopping/starting the bundle from the OSGi console and look for errors? You can also check /var/log/kura-console.log for any relevant errors. – David Woodard May 02 '18 at 20:05
  • Thanks for the quick reply! edits in response to your suggestion. Please let me know what you think! – forthlightning May 02 '18 at 21:21
  • Looks like a problem with the XML. I would make sure all of the XML elements are properly closed (ex: ). If possible, provide the component definition and metatype XML files. – David Woodard May 02 '18 at 22:30
  • More edits, thanks again! – forthlightning May 02 '18 at 23:19
  • Neil's point is valid. Also, I don't see any attribute definitions (i.e. ) in your metatype file. Is that on purpose? Have a look at a metatype example from the Kura project: https://github.com/eclipse/kura/blob/develop/kura/examples/org.eclipse.kura.demo.heater/OSGI-INF/metatype/org.eclipse.kura.demo.heater.Heater.xml – David Woodard May 04 '18 at 00:04
  • You're not writing the Metatype XML by hand are you?? – Neil Bartlett May 09 '18 at 07:53
  • Err yes? Well actually I have metatype XML files that are already implemented, that I tweak when I want to make a new bundle. The double question marks suggest that you are surprised at this and have a better solution, I'm all ears! – forthlightning May 11 '18 at 22:24

1 Answers1

2

This error message is probably the root cause of all the others:

org.osgi.framework.ServiceException: org.eclipse.equinox.internal.ds.ServiceReg.getService() returned a service object that is not an instance of the service class com.company.product.common.PayloadReadyNotifier

You have not shown the code for the implementation class com.company.product.statemachineXXXXimpl.StateMachineXXXXImpl. But the error suggest that it does not implement or extend the type com.company.product.common.PayloadReadyNotifier, which you have declared as a service interface for the component.

When you publish an OSGi service, the implementation class must be castable to all of the service interfaces that you attempt to publish under.

Neil Bartlett
  • 23,743
  • 4
  • 44
  • 77