我在Camel的FTP组件上有很多问题。我使用Apache 2.14.1和Apache 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但是,我还是会犯错误.
我发现这篇文章与我的Camel not finding "sftp" component in registry and shutting down有类似的问题,他们说使用OsgiDefaultCamelContext解决了问题,但我不认为我们可以使用它,因为我们使用的是SpringCamelContext…或者至少我还没有找到任何文档/示例来更改Springcontext.xml中的CamelContext类。
你能给我个建议吗?提前谢谢。
更新终于使这个工作!问题是,我这样声明模板:
producerTemplate = getContext().createProducerTemplate();这样,OSGI就没有被设置,错误就发生了。但是,我用以下内容更新了camel-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;还有哇!啊,真灵!
希望这能帮到别人!
发布于 2016-08-23 14:36:39
终于成功了!问题是,我这样声明模板:
producerTemplate = getContext().createProducerTemplate();这样,OSGI就没有被设置,错误就发生了。但是,我用以下内容更新了camel-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;还有哇!啊,真灵!
希望这能帮到别人!
https://stackoverflow.com/questions/32506674
复制相似问题