2014-04-26 51 views
2

我試圖將包導入由另一個包導出的Karaf運行時內的(.kar)包。當我在.kar文件的一個bean中引用這個包時,我得到一個錯誤。 我有一個包被導出包即「com.sample」Karaf包導入錯誤

當我運行包:出口,我可以看到在列表中被導出的包,但是當我從我的.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] 

我的清單外觀如下

​​

任何幫助將不勝感激!謝謝

回答

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」,選擇的方法和已經開始了!