【问题标题】:Cannot export Interface in OSGI无法在 OSGI 中导出接口
【发布时间】:2014-01-31 15:18:20
【问题描述】:

我正在尝试导出一个接口 (ITestRunable) 我确定我已经正确链接了 context.xml 和 osgi.xml 文件中的所有内容,但它无法正常工作。错误是:

“me.overlaymanagement”的应用程序上下文初始化已超时等待 (objectClass=me.overlaymanagement.testing.ITestRunable)

有人知道吗?

代码:ITestRunable 的 Spring 文件

context.xml

  <bean id="testingRunable"   class="me.overlaymanagement.testing.Testing"
init-method="startUp" destroy-method="shutDown">
  </bean>

osgi.xml

<osgi:service id="testingRunable" ref="testingRunable">
    <osgi:interfaces>
      <value>me.overlaymanagement.testing.ITestRunable</value>
    </osgi:interfaces>
 </osgi:service>

用于导入主系统的 Spring 文件

context.xml

<bean id="overlaymanagementsystem" 
    class="me.overlaymanagementsystem.OverlayManagementSystem"
    init-method="startUp" destroy-method="shutDown">
    <property name="testingRunable" ref="testingRunable"/>
 </bean>

osgi.xml

<osgi:reference id="testingRunable" cardinality="1..1"
  interface="me.overlaymanagement.testing.ITestRunable">      
</osgi:reference>

主系统中 ITestRunable 的 Gettors 和 Settors

public class OverlayManagementSystem{
     ...
    protected ITestRunable testingRunable;
    ....
    public ITestRunable getTestRunable() {
    return testingRunable;
    }   

    public void setTestRunable(ITestRunable testingRunable) {
    this.testingRunable = testingRunable;
    }
 }

谁能看出问题?

【问题讨论】:

    标签: java xml eclipse spring


    【解决方案1】:

    好的,所以我设法找到了问题。实际上是两件事:

    1. 它不喜欢我设置了 ITestRunable 代码所在的 bean id 和服务 id。一旦我将服务 ID 名称更改为不同的名称,它就会给我一个关于无效 gettor 和 settor 的新错误,这是下一点。

    2. 经过一些研究,我发现您的导入服务的 gettor 和 setter 必须与该服务的 beans 属性名称相同。在我的 bean 中注意它:

    get/set 定义为:“getTestRunable/setTestRunable”。将这些更改为 getTestingRunable 和 setTestingRunable 为我解决了这个问题。

    我希望这对其他人有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-12
      • 2012-12-15
      • 1970-01-01
      • 2015-03-25
      • 2017-05-12
      • 2012-10-11
      • 1970-01-01
      • 2017-05-31
      相关资源
      最近更新 更多