在Apache karaf上捆绑使用Apache camel



我试图将一些文件的内容写入Apache karaf的日志文件(只是为了一些测试)。要做到这一点,我使用下面的Route with Camel:

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

LogProcessor现在什么都不做,我的pom.xml看起来像这样(用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>

我也执行了

features:install camel-stream

在karaf上当然camel本身也被安装在karaf上

但是我仍然得到

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

卡拉出错。

已经看了很多论坛和东西,但找不到任何解决方案…任何帮助都是感激的!

这有点直觉,但我猜你已经在bundle Activator中创建了DefaultCamelContext。那么Stream Component就不会被加载到这个上下文中,除非你自己这样做:

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

相关内容

  • 没有找到相关文章

最新更新