2

I'm trying to run a standalone OSGi framework to run blueprint bundles within it that execute camel routes. The OSGi framework is Apache Felix, the blueprint implementation is Apache Aries.

The following bundles are loaded to the BundleContext of the framework:

Installed bundles

Now I have a test bundle that has a blueprint definition which contains a camelContext that looks as follows:

<?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>

Even though all the bundles are loaded and the requirements are resolved, the blueprint container gives the following log:

[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

The important line here is the Waiting for namespace handlers: the test bundle can't find the camel-blueprint namespace. But this namespace should be defined in the camel-blueprint bundle that is installed.

Without the camelContext in the blueprint, everything works (blueprint services are loaded and initialized).

Has anyone had similar problems with this? What is preventing the test bundle to have access to the camel-blueprint provided namespaces?

4

1 回答 1

0

We fixed this issue by cleaning up the dependencies. Only the following are actually required:

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

Also, to successfully get Camel to run inside Aries Blueprint, an additional parameter is required when instantiating the framework. This allows the bundles to access the sun.* packages.

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);
于 2016-11-15T14:59:34.810 回答