0

I have to read a file from SFTP server. But while reading it camel throws com.jcraft.jsch.SftpException: Permission denied. But i have read and write permission for the folder and files in it. I tried moving the file to .done folder with filezilla and it works.

Route:

sftp://USERNAME@IP_ADDRESS:PORT/path?password=MY_PASSWORD&move=.done&binary=true&disconnect=true&include=FILENAME_(2\\d{3})(\\d{2})(\\d{2}).txt

File Permissions

Stacktrace

o.a.c.c.file.remote.SftpConsumer         : Error processing file RemoteFile[FILENAME_20170802.txt] due to Cannot retrieve file: path/FILENAME_20170802.txt. Caused by: [org.apache.camel.component.file.GenericFileOperationFailedException - Cannot retrieve file: path/FILENAME_20170802.txt]

org.apache.camel.component.file.GenericFileOperationFailedException: Cannot retrieve file: path/FILENAME_20170802.txt
    at org.apache.camel.component.file.remote.SftpOperations.retrieveFileToStreamInBody(SftpOperations.java:704) ~[camel-ftp-2.19.1.jar:2.19.1]
    at org.apache.camel.component.file.remote.SftpOperations.retrieveFile(SftpOperations.java:648) ~[camel-ftp-2.19.1.jar:2.19.1]
    at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:408) [camel-core-2.19.1.jar:2.19.1]
    at org.apache.camel.component.file.remote.RemoteFileConsumer.processExchange(RemoteFileConsumer.java:137) [camel-ftp-2.19.1.jar:2.19.1]
    at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:218) [camel-core-2.19.1.jar:2.19.1]
    at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:182) [camel-core-2.19.1.jar:2.19.1]
    at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174) [camel-core-2.19.1.jar:2.19.1]
    at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101) [camel-core-2.19.1.jar:2.19.1]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_131]
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [na:1.8.0_131]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_131]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [na:1.8.0_131]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_131]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_131]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_131]
Caused by: com.jcraft.jsch.SftpException: Permission denied
    at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2873) ~[jsch-0.1.54.jar:na]
    at com.jcraft.jsch.ChannelSftp._stat(ChannelSftp.java:2225) ~[jsch-0.1.54.jar:na]
    at com.jcraft.jsch.ChannelSftp.get(ChannelSftp.java:1318) ~[jsch-0.1.54.jar:na]
    at com.jcraft.jsch.ChannelSftp.get(ChannelSftp.java:1290) ~[jsch-0.1.54.jar:na]
    at org.apache.camel.component.file.remote.SftpOperations.retrieveFileToStreamInBody(SftpOperations.java:689) ~[camel-ftp-2.19.1.jar:2.19.1]
    ... 14 common frames omitted
Ibrahim
  • 1,341
  • 1
  • 11
  • 24
  • if camel is throwing permission denied. it would be certainly permission related issue. Check how you are passing your credentials. The credentials provided in real have those rights. Check the camel ftp syntax used to connect to your FTP server. – sakura Aug 03 '17 at 10:07
  • Check if folder exists and the folder path is mentioned correctly in the camel route (i.e. syntax) try ./done. Further make sure the source file `FILENAME.txt` exists. you have some patterns associated with Filename however I don't see any thing in the name appended for Filename. – sakura Aug 03 '17 at 10:16
  • @sakura Updated file name. File exists in SFTP, also it prints the correct file name from correct path as well. In SFTP, given credential have permission to read and write file (checked with filezilla). But still i'm getting this error – Ibrahim Aug 03 '17 at 10:33
  • `path/FILENAME_20170802.txt` should it be `./path/FILENAME_20170802.txt`? try restarting sftp service and reconnect. – sakura Aug 03 '17 at 11:33

1 Answers1

0

The directory path that you have provided is relative, not absolute. Just confirming if that's the issue.

By default, Camel will go to /home/{username}/ directory. Not the "\" root directory.

Hope it helps.

Sukul Amrit
  • 75
  • 1
  • 10