2016-11-09 33 views
1

我試圖運行獨立的OSGi框架來運行其中執行駱駝路由的藍圖包。 OSGi框架是Apache Felix,藍圖實現是Apache Aries。藍圖聲明中沒有發現「camel-blueprint」命名空間(Felix中的白羊座)

以下束加載到框架的BundleContext

Installed bundles

現在我有具有其中包含一個camelContext看起來如下的藍圖定義一個測試包:

<?xml version="1.0" encoding="UTF-8"?> 
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation=" 
     http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd 
     http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd"> 

    <camelContext xmlns="http://camel.apache.org/schema/blueprint"> 
     <route id="testRoute1"> 
      <from uri="timer:foo?period=5000" /> 
      <log message="Hello world!" /> 
     </route> 
    </camelContext> 

</blueprint> 

儘管所有軟件包都已加載並且需求得到解決,但藍圖容器會提供以下日誌:

[de.hff.yosgi.test1.Test] : Installing test bundle 
[org.apache.aries.blueprint.container.BlueprintExtender] : Starting BlueprintContainer destruction process for bundle osgi-test1 
[org.apache.aries.blueprint.container.BlueprintExtender] : Not a blueprint bundle or destruction of BlueprintContainer already finished for osgi-test1. 
[org.apache.aries.blueprint.container.BlueprintExtender] : Starting BlueprintContainer destruction process for bundle osgi-test1 
[org.apache.aries.blueprint.container.BlueprintExtender] : Not a blueprint bundle or destruction of BlueprintContainer already finished for osgi-test1. 
[de.hff.yosgi.test1.Test] : Test bundle installed, starting 
[org.apache.aries.blueprint.container.BlueprintExtender] : Starting BlueprintContainer destruction process for bundle osgi-test1 
[org.apache.aries.blueprint.container.BlueprintExtender] : Not a blueprint bundle or destruction of BlueprintContainer already finished for osgi-test1. 
[org.apache.aries.blueprint.container.BlueprintExtender] : Starting BlueprintContainer destruction process for bundle osgi-test1 
[org.apache.aries.blueprint.container.BlueprintExtender] : Not a blueprint bundle or destruction of BlueprintContainer already finished for osgi-test1. 
[org.apache.aries.blueprint.container.BlueprintExtender] : Scanning bundle osgi-test1 for blueprint application 
[org.apache.aries.blueprint.container.BlueprintExtender] : Found blueprint application in bundle osgi-test1 with paths: [bundle://24.0:0/OSGI-INF/blueprint/blueprint.xml] 
[org.apache.aries.blueprint.container.BlueprintExtender] : Scheduling creation of blueprint bundle osgi-test1 asynchronously 
[org.apache.aries.blueprint.container.BlueprintContainerImpl] : Running blueprint container for bundle osgi-test1 in state Unknown 
[org.apache.aries.blueprint.container.BlueprintEventDispatcher] : Sending blueprint container event BlueprintEvent[type=CREATING] for bundle osgi-test1 
[de.hff.yosgi.test1.Test] : Test bundle started 
[org.apache.aries.blueprint.container.BlueprintContainerImpl] : Running blueprint container for bundle osgi-test1 in state WaitForNamespaceHandlers 
[org.apache.aries.blueprint.container.BlueprintContainerImpl] : Bundle osgi-test1 is waiting for namespace handlers [http://camel.apache.org/schema/blueprint] 
[org.apache.aries.blueprint.container.BlueprintEventDispatcher] : Sending blueprint container event BlueprintEvent[type=GRACE_PERIOD, dependencies=[(&(objectClass=org.apache.aries.blueprint.NamespaceHandler)(osgi.service.blueprint.namespace=http://camel.apache.org/schema/blueprint))]] for bundle osgi-test1 

這裏最重要的線是Waiting for namespace handlers:測試包找不到駱駝藍圖的命名空間。但是這個命名空間應該在安裝的駱駝藍圖包中定義。

沒有camelContext在藍圖中,一切正常(藍圖服務加載和初始化)。

有沒有人有類似的問題呢?什麼阻止測試包訪問駱駝藍圖提供的名稱空間?

+0

您需要將駱駝依賴性安裝到OSGi框架中。如駱駝核心,駱駝藍圖等。 –

+0

@ClausIbsen請參閱'camel-blueprint-2.18.0.jar'和'camel-core-2.18.0.jar' ;-)問題是,安裝的JAR會產生衝突,我會盡快爲此添加一個答案。 – maxdev

回答

0

我們通過清理依賴關係來解決此問題。只有實際需要如下:

Dependencies required to run an OSGi Felix standalone with Aries and Camel

此外,爲了順利拿到駱駝白羊座藍圖內運行,實例化框架時的附加參數是必需的。這允許捆綁包訪問sun.*包。

Iterator<FrameworkFactory> iterator = 
     ServiceLoader.load(FrameworkFactory.class).iterator(); 
FrameworkFactory factory = iterator.next(); 

Map<> configuration = new HashMap<String, String>(); 
configuration.put("org.osgi.framework.bootdelegation", "sun.*"); 
this.framework = factory.newFramework(configuration);