Karaf包导入错误

时间:2014-04-26 14:49:54

标签: osgi manifest karaf

我正在尝试将包导入到另一个包导出的Karaf运行时中的(.kar)包。当我从.kar文件中的bean中引用此包时,我收到错误。 我有一个导出包的包,即“com.sample”

当我运行包时:exports我可以看到列表中正在导出的包,但是当我从.kar文件中引用它时,我收到以下错误:

The import com.sample cannot be resolved

at beans.testBean.<init>(testBean.java:5)
at bios.testdabean_0_1.testdabean$1.getCamelContextMap(testdabean.java:146)
at org.apache.camel.main.MainSupport.postProcessContext(MainSupport.java:386)
at bios.testdabean_0_1.testdabean$1.doStart(testdabean.java:161)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.main.MainSupport.run(MainSupport.java:148)
at bios.testdabean_0_1.testdabean.run(testdabean.java:194)
at bios.testdabean_0_1.testdabean.runJobInTOS(testdabean.java:290)
at org.talend.esb.job.controller.internal.RouteAdapter.run(RouteAdapter.java:78)[189:org.talen
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_51]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_51]

我的清单如下

Manifest-Version: 1.0
Export-Package: ...
Bundle-ClassPath: ...
Bundle-Name: ...
Export-Service: ...
Require-Bundle: ...
Bundle-Vendor: ...
Bundle-Version: 0.1
Bundle-ManifestVersion: 2
Bundle-SymbolicName: .....
Import-Package: com.sample,org.osgi.service.blueprint,javax.xml.bind.annotation,
 ...

任何帮助将不胜感激!感谢

1 个答案:

答案 0 :(得分:0)

如果有人有兴趣,我找到了解决方案。

我要做的是编辑路径Manifest文件以导入正在OSGi容器中导出的包。 之后,我不得不通过Studio中的Spring DM编辑器引用该服务。

我将命名空间更改为如下所示。

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:camel="http://camel.apache.org/schema/spring"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:osgi="http://www.springframework.org/schema/osgi"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/bean/spring-  beans.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
    http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
    http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">

之后,我可以通过标签

引用该服务
<osgi:reference id="myUDPService" interface="com.myosgi.UDPService"/>

一旦我完成了这个,我就删除了一个cBean,并通过Id&#34; myUDPService&#34;引用了bean,选择了该方法并且设置为了!