繁体   English   中英

Apache Camel FTP获取无法检索文件:RemoteFile错误

[英]Apache Camel FTP getting Cannot retrieve file: RemoteFile error

我正在尝试使用Camel FTP组件(Camel 2.19.0)检索文件:

from("ftp://my.host.com:21/my/relative/directory?download=true&stepwise=false&delete=false")

Camel正在正确连接并列出目录中的文件,但是在处理它们时,它会为每个文件引发以下异常:

org.apache.camel.component.file.GenericFileOperationFailedException: Cannot retrieve file: RemoteFile[my/relative/directory/file1.txt] from: ftp://my.host.com:21/my/relative/directory?delete=false&download=true&stepwise=false
    at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:427)
    at org.apache.camel.component.file.remote.RemoteFileConsumer.processExchange(RemoteFileConsumer.java:137)
    at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:218)
    at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:182)
    at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174)
    at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)

从TRACE日志中,我可以看到Camel正确列出了目录中的文件:

[TRACE] 2017-09-05 11:40:49,438 org.apache.camel.component.file.remote.FtpConsumer - Polling directory: my/relative/directory
[TRACE] 2017-09-05 11:40:51,748 org.apache.camel.component.file.remote.FtpOperations - listFiles(my/relative/directory)
[TRACE] 2017-09-05 11:40:58,657 org.apache.camel.component.file.remote.FtpConsumer - Found 3 in directory: my/relative/directory
[TRACE] 2017-09-05 11:40:58,657 org.apache.camel.component.file.remote.FtpConsumer - FtpFile[name=/absolute/path/to/directory/file1.txt, dir=false, file=true]
[TRACE] 2017-09-05 11:40:58,657 org.apache.camel.component.file.remote.FtpConsumer - FtpFile[name=/absolute/path/to/directory/file2.txt, dir=false, file=true]
[TRACE] 2017-09-05 11:40:58,657 org.apache.camel.component.file.remote.FtpConsumer - FtpFile[name=/absolute/path/to/directory/file3.txt, dir=false, file=true]

但是,当Camel尝试处理每个文件时,它似乎是将相对目录放在绝对目录的前面,并且找不到找到的乱码路径:

[TRACE] 2017-09-05 11:40:59,417 org.apache.camel.component.file.remote.FtpConsumer - Processing file: RemoteFile[absolute/path/to/directory/file1.txt]
[TRACE] 2017-09-05 11:40:59,418 org.apache.camel.component.file.remote.FtpConsumer - Retrieving file: my/relative/directory//absolute/path/to/directory/file1.txt from: ftp://my.host.com:21/my/relative/directory?delete=false&download=true&stepwise=false
[TRACE] 2017-09-05 11:40:59,418 org.apache.camel.component.file.remote.FtpOperations - retrieveFile(my/relative/directory//absolute/path/to/directory/file1.txt)
[TRACE] 2017-09-05 11:40:59,418 org.apache.camel.component.file.remote.FtpOperations - Client retrieveFile: my/relative/directory//absolute/path/to/directory/file1.txt
[WARN ] 2017-09-05 11:40:59,518 org.apache.camel.component.file.remote.FtpConsumer - Error processing file RemoteFile[absolute/path/to/directory/file1.txt] due to Cannot retrieve file: RemoteFile[absolute/path/to/directory/file1.txt] from: ftp://my.host.com:21/my/relative/directory?delete=false&download=true&stepwise=false

FTPComponent构造的日志中的此路径不正确:

检索文件:my / relative / directory // absolute / path / to / directory / file1.txt

我调试了Camel FTP使用者,看起来在第238行是相对路径被放在绝对路径之前

有趣的是, SFTP组件正在执行相同的操作,但是它却可以正常工作,因为RemoteFileOperations<ChannelSftp.LsEntry>并未将文件名设置为绝对路径,而RemoteFileOperations<FTPFile>可以。

有没有人有任何建议来解决此问题,以使FTP组件使用这些文件? 还是我做错了什么?

我正在使用骆驼2.19.0

默认情况下,骆驼将转到\\ home {username} \\目录。
如果您的文件位于此文件的相对路径下,则只需将目录路径指定为\\ abc-any-path \\ file.txt
如果您的文件保存在\\ home {username} \\以外的任何其他路径,那么在这种情况下,您需要
\\ .. \\ .. \\ abc-any-absolute-path \\ file.txt

骆驼不允许您直接输入绝对路径。 希望这可以帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM