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 に答える