Milla
Milla

Reputation: 503

Using Apache camel in bundles on Apache karaf

I'm trying to write the content of some files into the log file of Apache karaf (just for some testing). To do that I use the following Route with Camel:

from("file:C:/input?noop=true").process(new LogProcessor()).to(
            "stream:out");

The LogProcessor does nothing right now and my pom.xml looks like this (building it with maven):

    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0      http://maven.apache.org/xsd/maven-4.0.0.xsd">

<!--

    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->

<modelVersion>4.0.0</modelVersion>

<groupId>osgi</groupId>
<artifactId>osgi</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>bundle</packaging>

<name>osgi Bundle</name>
<description>osgi OSGi bundle project.</description>

<dependencies>
    <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.core</artifactId>
        <version>4.2.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-core</artifactId>
        <version>2.14.3</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.5</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-stream</artifactId>
        <version>2.14.3</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>2.3.7</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Bundle-SymbolicName>osgi</Bundle-SymbolicName>
                    <Bundle-Version>1.0-SNAPSHOT</Bundle-Version>
                    <Bundle-Activator>osgi.Activator</Bundle-Activator>
                    <Export-Package>
                        osgi*;version=1.0-SNAPSHOT
                    </Export-Package>
                    <Import-Package>
                        *
                    </Import-Package>
                </instructions>
            </configuration>
        </plugin>
    </plugins>
</build>

I also executed

features:install camel-stream

on karaf and of course camel itself is also installed on karaf.

But still I get the

[...]No component found with scheme: stream[...]

Error on karaf.

Already looked through a lot of Forums and stuff but couldn't find any solution...any help is appreciated!

Upvotes: 2

Views: 959

Answers (1)

jnupponen
jnupponen

Reputation: 745

This is bit of a hunch but I'm guessing you've created DefaultCamelContext inside bundle Activator. Then Stream Component is not loaded in to that context unless you do it yourself like this:

StreamComponent stream = new StreamComponent();
camelContext.addComponent("stream", stream);

Upvotes: 3

Related Questions