2

我正在开发一个基于 OSGI 的系统,它使用声明性服务来定义组件。但是,当从 Eclipse 运行它时,我的组件之一未初始化。当我使用简单的控制台命令调查问题时,我得到以下输出(带有一些小混淆):

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:

所以组件有state = Unsatisfied,但是动态信息表明组件是满足的并且它的组件引用也被满足。

有人可以解释一下吗?为什么我的组件没有初始化?

更新:显然,immedate="true"组件的设置修复了初始化问题。osgi 命令仍然有state = Unsatisfied。有人知道为什么吗?

4

2 回答 2

3

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.

于 2014-12-12T15:18:53.583 回答
0

请记住,组件的构造函数不能有参数。

此外,强制启用标签enabled="true" immediate="true"中的属性。<scr:component>

于 2015-04-22T09:05:28.990 回答