[
https://issues.apache.org/jira/browse/CAMEL-11754?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16164224#comment-16164224
]
Önder Sezgin commented on CAMEL-11754:
--------------------------------------
The reason i ask you to create failing test case, i can not recreate your
{{my/relative/directory}} and {{/absolute/path/to/directory/file1.txt}} and how
you structure your route to collect and get such logs like;
{code}
[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,
{code}
because absolute path's prefix with {{File.separator}} or {{'/'}} is dropped
and you unlikely reach line 238 in FtpConsumer.java with variable {{dir}}
starting with slash character and file.getName() as the whole absolute path.
And as all the other tests already pass, I have to mark unreproducable unless
you provide it. You can repoen if you face the issue with proper failing unit
test.
well IMHO, recreating such issue would be much easier to rewrite an FTP
client, though.
> Apache Camel FTP getting Cannot retrieve file: RemoteFile error
> ---------------------------------------------------------------
>
> Key: CAMEL-11754
> URL: https://issues.apache.org/jira/browse/CAMEL-11754
> Project: Camel
> Issue Type: Bug
> Components: camel-ftp
> Affects Versions: 2.19.0
> Environment: Windows 10 x64
> jdk1.8.0_131
> Camel 2.19.0
> Reporter: dheitzer
>
> I'm receiving an error from the FTP Component when its processing files in
> Camel 2.19.0.
> I'm trying to retrieve files using the Camel FTP component (Camel 2.19.0):
> from("ftp://my.host.com:21/my/relative/directory?download=true&stepwise=false&delete=false")
> {code:java}
> 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)
> {code}
> From the TRACE logs, I can see that Camel is listing the files in the
> directory correctly:
> {code:java}
> [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]
> {code}
> When Camel tries to process each file however, it appears to be prepending
> the relative directory to the absolute directory and failing to find the
> resulting garbled path:
> {code:java}
> [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
> {code}
> This path in the logs constructed by the FTPComponent is incorrect:
> {noformat}
> Retrieving file: my/relative/directory//absolute/path/to/directory/file1.txt
> {noformat}
> I debugged the Camel FTP consumer and it looks like
> [on line 238 is where the relative path is getting prepended to the absolute
> path|https://github.com/apache/camel/blob/camel-2.19.x/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java#L238]
> Interestingly enough, [the SFTP component is doing the same
> thing|https://github.com/apache/camel/blob/camel-2.19.x/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java#L208]
> however it is working because
> {code:java}
> RemoteFileOperations<ChannelSftp.LsEntry>
> {code}
> does not set filename as an absolute path but
> {code:java}
> RemoteFileOperations<FTPFile>
> {code}
> does.
> Does anyone have any suggestions to work around this to get the FTP Conponent
> to consume the files? or am I doing something incorrectly?
> I'm using Camel 2.19.0
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)