osgi服务:不满足活动服务的参考

osgi服务:不满足活动服务的参考,osgi,Osgi,我有一个不满意的osgi服务: ls 142 Components in bundle A: ID State Component Name Located in bundle 90 Unsatisfied ServiceA A(bid=142) 对服务B的引用不满意: comp 90 Component[ name = ServiceA activate = activate deact

我有一个不满意的osgi服务:

ls 142
Components in bundle A: 
ID  State           Component Name          Located in bundle
90  Unsatisfied     ServiceA            A(bid=142)
对服务B的引用不满意:

comp 90
    Component[
    name = ServiceA
    activate = activate
    deactivate = deactivate
    modified = 
    configuration-policy = optional
    factory = null
    autoenable = true
    immediate = false
    implementation = ServiceA
    state = Unsatisfied
    properties = 
    serviceFactory = false
    serviceInterface = [ServiceA]
    references = {
        Reference[name = ServiceB, interface = ServiceB, policy = static, cardinality = 1..1, target = null, bind = setServiceB, unbind = unsetServiceB]
    }
    located in bundle = B_2.12.0.qualifier [142]
]
Dynamic information :
  *The component is NOT satisfied
  The following references are not satisfied:
    Reference[name = ServiceB, interface = ServiceB, policy = static, cardinality = 1..1, target = null, bind = setServiceB, unbind = unsetServiceB]
  Component configurations :
    Configuration properties:
      component.name = ServiceA
      component.id = 136
      objectClass = String[ServiceA]
    Instances:
然而,ServiceB是活跃的:

ls 52
Components in bundle B: 
ID  State           Component Name          Located in bundle
14  Active      ServiceB            B(bid=52)
那么,为什么从ServiceA到ServiceB的引用不令人满意呢?重新启动捆绑包A(停止和启动)没有帮助。在捆绑包C中的工作服务C上配置引用会使服务C不满意

更新:ServiceB已注册 osgi控制台中“services”命令的结果包含以下内容:

{ServiceB}={service.id=180}
  Registered by bundle: Z_2.12.0.qualifier [123]
  No bundles using service.
附加信息:服务A和服务B的配置、初始化和注册 ServiceB基本上是一个apachecxfweb服务,它实现了一个接口。此接口是从wsdl生成的。ServiceB是以编程方式注册的。ServiceA引用了生成的接口。此模式与另一个web服务(比如ServiceC和ServiceD)完美结合。

如果有帮助的话:在升级ApacheCXF之前,这种模式甚至可以在ServiceA和ServiceB之间工作。我以前没有提供这些信息,因为我担心这会使问题变得太复杂我找到了一个解决方法,可以通过编程方式访问ServiceB:

ServiceTracker st = new ServiceTracker(context, ServiceB.class.getName(), null);
st.open(true);
st.getService()
open方法中的boolean参数起到了作用


不幸的是,我无法回答为什么有些bundle可以“直接”访问ServiceB(open方法中不需要参数),而有些bundle需要“true”参数。

组件ServiceB是什么样子的?“我怀疑它没有导出服务。”克里斯蒂安施奈德说,这是一个很好的暗示。我仍在调查中。您能将组件B的设置添加到问题中吗?可能两个捆绑包没有使用包含WebServiceConfig接口的同一个包。@BjarGrave很好,但此接口(ServiceB)在我的工作区中只存在一次。所有捆绑包依赖项都设置为当前快照版本。包含接口的包只存在一次(也在运行时)。该接口包含在bundle B中。