未找到具有以下方案的组件:sftp Apache Camel 2.14.1、ServiceMix 5.2.0

No component found with scheme: sftp Apache Camel 2.14.1, ServiceMix 5.2.0

我在使用 Camel 的 FTP 组件时遇到了很多问题。我正在使用 Apache Camel 2.14.1 和 Apache ServiceMix 5.2.0

问题是每当我尝试进行 FTP/SFTP 传输时都会收到此错误:

org.apache.camel.ResolveEndpointFailedException: 
Failed to resolve endpoint: sftp://user@sftp_url/test?binary=true&fileName=destinationFile.txt 
due to: No component found with scheme: sftp

我确保在 ServiceMix 中正确安装了所需的组件

karaf@pos-interfaces> list | grep camel-
[ 124] [Active     ] [            ] [       ] [   50] camel-core (2.14.1)
[ 125] [Active     ] [Created     ] [       ] [   50] camel-karaf-commands (2.14.1)
[ 126] [Active     ] [            ] [       ] [   50] camel-jms (2.14.1)
[ 132] [Active     ] [            ] [       ] [   50] camel-spring (2.14.1)
[ 133] [Active     ] [Created     ] [       ] [   50] camel-blueprint (2.14.1)
[ 213] [Active     ] [            ] [       ] [   50] camel-http (2.14.1)
[ 214] [Active     ] [            ] [       ] [   50] camel-jetty (2.14.1)
[ 271] [Active     ] [            ] [       ] [   50] camel-exec (2.14.1)
[ 285] [Active     ] [            ] [       ] [   50] camel-quartz2 (2.14.1)
[ 287] [Active     ] [            ] [       ] [   90] camel-jaxb (2.14.1)
[ 572] [Active     ] [            ] [       ] [   50] camel-ftp (2.14.1)
[ 573] [Active     ] [            ] [       ] [   50] camel-jsch (2.14.1)

我什至添加了一些代码来检查“ftp/sftp”组件是否已经在上下文中并且已启动(如果没有,我将强制启动它)。这是日志中打印的内容:

| DEBUG | xtenderThread-56 | RouteBuilder      | ? | sftp component already there...
| DEBUG | xtenderThread-56 | RouteBuilder      | ? | sftp original status...Stopped
| DEBUG | xtenderThread-56 | RouteBuilder      | ? | sftp starting manually...
| DEBUG | xtenderThread-56 | RouteBuilder      | ? | final sftp status...Started

但是,我仍然收到错误...

我发现这篇文章与我的文章 有类似的问题,他们说使用 OsgiDefaultCamelContext 解决了问题,但我认为我们不能使用它,因为我们正在使用 SpringCamelContext... 或者至少我还没有找到任何 documentation/example 来更改 spring-context.xml

中的 CamelContext class

能请教一下吗?提前致谢。

[更新] 终于成功了! 问题是我这样声明模板:

producerTemplate = getContext().createProducerTemplate();

那样的话,OSGI 没有被设置,错误就发生了。 但是后来,我用这个更新了我的骆驼-context.xml:

<camelContext trace="false" id="camelContext"
    xmlns="http://camel.apache.org/schema/spring">
    <template id="producerTemplate"/>
    <routeBuilder ref="routeBuilder" />
</camelContext>

还有我的路线建设者:

@BeanInject("producerTemplate")
private transient ProducerTemplate producerTemplate;

瞧!成功了!

希望这对某人有所帮助!

终于成功了!问题是我这样声明模板:

producerTemplate = getContext().createProducerTemplate();

那样的话,OSGI 没有被设置,错误就发生了。但是后来,我用这个更新了我的骆驼-context.xml:

<camelContext trace="false" id="camelContext"
    xmlns="http://camel.apache.org/schema/spring">
    <template id="producerTemplate"/>
    <routeBuilder ref="routeBuilder" />
</camelContext>

还有我的路线建设者:

@BeanInject("producerTemplate")
private transient ProducerTemplate producerTemplate;

瞧!成功了!

希望这对某人有所帮助!