簡體   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