我正在使用骆驼版本 2.15.2
我有一个端点
final String endpoint = "sftp://myUsername@$myHost:22/test-dir/?connectTimeout=5000&password=MySuperSecretPassword&ignoreFileNotFoundOrPermissionError=false&fileName=FABT_Index_DE.xls&delete=false&localWorkDirectory=/test-dir/
我执行以下操作从 SFTP 获取命名文件
@Autowired
private CamelContext camelContext;
...some Stuff...
private Exchange fetchFile(final String enpoint, final long timeout) {
final ConsumerTemplate consumer = camelContext.createConsumerTemplate();
return consumer.receive(endpoint, timeout);
}
当我在我的电脑(OS = windows)上启动我的应用程序时......一切都很好。该文件从 SFTP 获取。如果应用程序在另一台机器上运行,我认为测试是个好主意......所以我将我的 jar 复制到 SFTP(OS = linux)并在那里运行......(它是文件所在的同一台机器放置)
现在我得到以下异常:
2015-07-16 15:27:37,117 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpConsumer: postPollCheck on sftp://myUsername@myHost:22
2015-07-16 15:27:37,117 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.camel.impl.ScheduledPollConsumer: Polled 1 messages
2015-07-16 15:27:37,117 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.camel.impl.ScheduledPollConsumer: Finished polling: Endpoint[sftp://myUsername@myHost:22/test-dir/?connectTimeout=5000&delete=false&fileName=FABT_Index_DE.xls&ignoreFileNotFoundOrPermissionError=false&localWorkDirectory=%2Ftest-dir%2F&password=xxxxxx]
2015-07-16 15:27:37,118 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.camel.impl.ScheduledPollConsumer: doRun() done with idleCounter=0, errorCounter=0
2015-07-16 15:27:37,118 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.camel.impl.ScheduledPollConsumer: Scheduled task completed on: Endpoint[sftp://myUsername@myHost:22/test-dir/?connectTimeout=5000&delete=false&fileName=FABT_Index_DE.xls&ignoreFileNotFoundOrPermissionError=false&localWorkDirectory=%2Ftest-dir%2F&password=xxxxxx]
2015-07-16 15:27:37,619 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.camel.impl.ScheduledPollConsumer: Scheduled task started on: Endpoint[sftp://myUsername@myHost:22/test-dir/?connectTimeout=5000&delete=false&fileName=FABT_Index_DE.xls&ignoreFileNotFoundOrPermissionError=false&localWorkDirectory=%2Ftest-dir%2F&password=xxxxxx]
2015-07-16 15:27:37,620 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.camel.impl.ScheduledPollConsumer: Starting to poll: Endpoint[sftp://myUsername@myHost:22/test-dir/?connectTimeout=5000&delete=false&fileName=FABT_Index_DE.xls&ignoreFileNotFoundOrPermissionError=false&localWorkDirectory=%2Ftest-dir%2F&password=xxxxxx]
2015-07-16 15:27:37,620 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpConsumer: prePollCheck on sftp://myUsername@myHost:22
2015-07-16 15:27:37,621 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpOperations: getCurrentDirectory()
2015-07-16 15:27:37,621 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpOperations: Current dir: /vol2/home/myUsername
2015-07-16 15:27:37,621 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpConsumer: doPollDirectory from absolutePath: test-dir, dirName: null
2015-07-16 15:27:37,621 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpOperations: changeCurrentDirectory(test-dir)
2015-07-16 15:27:37,621 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpOperations: Compacted path: test-dir -> test-dir using separator: /
2015-07-16 15:27:37,621 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpOperations: getCurrentDirectory()
2015-07-16 15:27:37,621 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpOperations: Current dir: /vol2/home/myUsername
2015-07-16 15:27:37,621 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpOperations: Changing directory: test-dir
2015-07-16 15:27:37,622 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpConsumer: Polling directory: test-dir
2015-07-16 15:27:37,622 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpOperations: listFiles(.)
2015-07-16 15:27:37,624 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpConsumer: Found 9 in directory: test-dir
2015-07-16 15:27:37,625 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpConsumer: SftpFile[fileName=FASM_Index_DE.xls, longName=-rw-r--r-- 1 myUsername users 81920 Jun 30 16:46 FASM_Index_DE.xls, dir=false]
2015-07-16 15:27:37,625 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.i.c.DefaultTypeConverter: Converting java.lang.String -> java.lang.String with value: FABT_Index_DE.xls
2015-07-16 15:27:37,625 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpConsumer: File did not match. Will skip this file: RemoteFile[FASM_Index_DE.xls]
2015-07-16 15:27:37,625 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpConsumer: SftpFile[fileName=.., longName=drwxr-xr-x 8 myUsername users 4096 Jul 16 15:27 .., dir=true]
2015-07-16 15:27:37,625 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpConsumer: SftpFile[fileName=., longName=drwxr-xr-x 2 myUsername users 4096 Jul 16 15:24 ., dir=true]
2015-07-16 15:27:37,625 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpConsumer: SftpFile[fileName=FABT_Index_DE.xls, longName=-rw-r--r-- 1 myUsername users 129024 Jun 30 16:46 FABT_Index_DE.xls, dir=false]
2015-07-16 15:27:37,625 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpConsumer: SftpFile[fileName=test.txt, longName=-rw-r--r-- 1 myUsername users 18 Jul 16 15:24 test.txt, dir=false]
2015-07-16 15:27:37,625 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpConsumer: File did not match. Will skip this file: RemoteFile[test.txt]
2015-07-16 15:27:37,626 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpConsumer: SftpFile[fileName=FAWH_Index_DE.xls, longName=-rw-r--r-- 1 myUsername users 180224 Jun 30 16:46 FAWH_Index_DE.xls, dir=false]
2015-07-16 15:27:37,626 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpConsumer: File did not match. Will skip this file: RemoteFile[FAWH_Index_DE.xls]
2015-07-16 15:27:37,626 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpConsumer: SftpFile[fileName=FAPG_Index_DE.xls, longName=-rw-r--r-- 1 myUsername users 101888 Jun 30 16:46 FAPG_Index_DE.xls, dir=false]
2015-07-16 15:27:37,626 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpConsumer: File did not match. Will skip this file: RemoteFile[FAPG_Index_DE.xls]
2015-07-16 15:27:37,626 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpConsumer: SftpFile[fileName=FAPP_Index_DE.xls, longName=-rw-r--r-- 1 myUsername users 78336 Jun 30 16:46 FAPP_Index_DE.xls, dir=false]
2015-07-16 15:27:37,626 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpConsumer: File did not match. Will skip this file: RemoteFile[FAPP_Index_DE.xls]
2015-07-16 15:27:37,626 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpConsumer: SftpFile[fileName=FAHG_Index_DE.xls, longName=-rw-r--r-- 1 myUsername users 149504 Jun 30 16:46 FAHG_Index_DE.xls, dir=false]
2015-07-16 15:27:37,626 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpConsumer: File did not match. Will skip this file: RemoteFile[FAHG_Index_DE.xls]
2015-07-16 15:27:37,626 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpOperations: changeCurrentDirectory(/vol2/home/myUsername)
2015-07-16 15:27:37,627 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpOperations: Compacted path: /vol2/home/myUsername -> /vol2/home/myUsername using separator: /
2015-07-16 15:27:37,627 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpOperations: getCurrentDirectory()
2015-07-16 15:27:37,627 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpOperations: Current dir: /vol2/home/myUsername/test-dir
2015-07-16 15:27:37,627 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpOperations: getCurrentDirectory()
2015-07-16 15:27:37,627 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpOperations: Current dir: /vol2/home/myUsername/test-dir
2015-07-16 15:27:37,627 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpOperations: Changing directory: ..
2015-07-16 15:27:37,628 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] DEBUG o.a.c.c.file.remote.SftpConsumer: Took 0.007 seconds to poll: test-dir/
2015-07-16 15:27:37,628 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] DEBUG o.a.c.c.file.remote.SftpConsumer: Total 1 files to consume
2015-07-16 15:27:37,628 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpConsumer: Processing file: RemoteFile[FABT_Index_DE.xls]
2015-07-16 15:27:37,628 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpConsumer: Retrieving file: test-dir/FABT_Index_DE.xls from: Endpoint[sftp://myUsername@myHost:22/test-dir/?connectTimeout=5000&delete=false&fileName=FABT_Index_DE.xls&ignoreFileNotFoundOrPermissionError=false&localWorkDirectory=%2Ftest-dir%2F&password=xxxxxx]
2015-07-16 15:27:37,629 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] TRACE o.a.c.c.file.remote.SftpOperations: retrieveFile(test-dir/FABT_Index_DE.xls)
2015-07-16 15:27:37,630 [Camel (camel-1) thread #0 - sftp://myUsername@myHost:22/test-dir/] WARN o.a.c.c.file.remote.SftpConsumer: Error processing file RemoteFile[FABT_Index_DE.xls] due to Cannot create new local work file: /test-dir/FABT_Index_DE.xls.
Caused by: [org.apache.camel.component.file.GenericFileOperationFailedException - Cannot create new local work file: /test-dir/FABT_Index_DE.xls]
org.apache.camel.component.file.GenericFileOperationFailedException: Cannot create new local work file: /test-dir/FABT_Index_DE.xls
at org.apache.camel.component.file.remote.SftpOperations.retrieveFileToFileInLocalWorkDirectory(SftpOperations.java:702) ~[aii.jar:na]
at org.apache.camel.component.file.remote.SftpOperations.retrieveFile(SftpOperations.java:591) ~[aii.jar:na]
at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:396) [aii.jar:na]
at org.apache.camel.component.file.remote.RemoteFileConsumer.processExchange(RemoteFileConsumer.java:137) [aii.jar:na]
at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:211) [aii.jar:na]
at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:175) [aii.jar:na]
at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174) [aii.jar:na]
at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101) [aii.jar:na]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [na:1.7.0_45]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304) [na:1.7.0_45]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178) [na:1.7.0_45]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.7.0_45]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_45]
at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45]
谁能告诉我为什么我得到这个异常 - 而不是从 SFTP 获取文件?