2

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

当我运行 packages: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,
 ...

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

4

1 回答 1

0

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

我需要做的是编辑路由清单文件以导入在 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“myUDPService”引用了 bean,选择了方法并设置好了!

于 2014-05-08T15:03:00.520 回答