gpt4 book ai didi

java - 从 SFTP 使用文件期间无法创建新的本地工作文件

转载 作者:行者123 更新时间:2023-12-01 11:19:14 25 4
gpt4 key购买 nike

我使用的是camel版本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);
}

当我在我的电脑(操作系统 = 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 获取文件?

最佳答案

我发现了以下内容:

我为端点和本地工作目录使用了相同的字符串test-dir。经过一些实验,似乎对于端点定义

  • 最终字符串端点 = "sftp://myUsername@$myHost:22/test-dir/?connect ...

test-dir 是相对路径。例如此目录位于 /vol/usr/home/MyTestUser/test-dir/vol/usr/home/myUsername/ 是 SFTP- 的主目录用户(或者通过 ssh 登录时获得的目录) - 可以使用 /test-dir/

定义端点

但是对于选项localWorkDirectory

  • 最终字符串端点 = "... &localWorkDirectory=/test-dir/..."

看来test-dir是绝对路径。因为我尝试在 SFTP 上运行应用程序,所以我没有权限写入绝对目录 /test-dir/ 所以我将此目录更改为 /vol/usr/home/myUsername/MyTempDirectory/ 并添加选项 &stepwise=false。现在它起作用了。端点现在是:

final String endpoint = "sftp://myUsername@myHost:22/test-dir/connectTimeout=5000&password=MySuperSecretPassword&ignoreFileNotFoundOrPermissionError=false&fileName=FABT_Index_DE.xls&delete=false&localWorkDirectory=/vol/usr/home/myUsername/MyTempDirectory/&stepwise=false";

也许有人可以更准确地澄清它......

关于java - 从 SFTP 使用文件期间无法创建新的本地工作文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31456516/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com