Windows 上的 Apache Camel 和 Apache FTP 服务器 - 找不到 "from" 目录

Apache Camel and Apache FTP Server on Windows - Can't find the "from" directory

我正在尝试使用带有 FTP 组件的 Apache Camel 设置一个 FTP 客户端。我目前正在使用 Apache FTP Server (https://mina.apache.org/ftpserver-project/index.html) 作为服务器实现。我正在 运行 将服务器与提供的独立服务器连接起来。目前这是在 Windows 10 盒子上完成的,但最终将在 Linux 环境中使用。

我 运行 服务器提供 "typical" 配置,允许匿名登录,端口 2121。

C:\Users\JO24447\Applications\apache-ftpserver-1.1.1\bin>ftpd.bat C:\Users\JO24447\Applications\apache-ftpserver-1.1.1\res\conf\ftpd-typical.xml
Using XML configuration file C:\Users\JO24447\Applications\apache-ftpserver-1.1.1\res\conf\ftpd-typical.xml...
FtpServer started

我的 FTP 路由设置如下:

<route id="ftp-get">
  <from uri="ftp://{{ftp-client.server.host}}:{{ftp-client.server.port}}/{{ftp-client.source-dir}}?separator=Windows" />
  <log loggingLevel="INFO" message="start - ftp-get" />
  <to uri="file:{{ftp-client.dest-dir}}" />
  <log loggingLevel="INFO" message="end - ftp-get" />
</route>

注意:我尝试将 separator 设置为 AutoWindows,但结果相同。

我的属性设置如下 (application.yml):

ftp-client:
  server:
    host: localhost
    port: 2121
  source-dir: C:\Users\JO24447\workspace\mission_services_camel\mission-services-camel\ftp-client\src\main\resources\source
  dest-dir: dest

当我 运行 客户端时,我收到错误提示找不到路径。 FTP 服务器日志显示类似的错误:

控制台:

  .   ____          _            __ _ _
 /\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.4.RELEASE)

[...]
2020-04-23 08:51:40.098  INFO 10440 --- [           main] o.a.c.i.e.AbstractCamelContext           : Route: ftp-get started and consuming from: ftp://localhost:2121/C:%5CUsers%5CJO24447%5Cworkspace%5Cmission_services_camel%5Cmission-services-camel%5Cftp-client%5Csrc%5Cmain%5Cresources%5Csource
2020-04-23 08:51:40.102  INFO 10440 --- [           main] o.a.c.i.e.AbstractCamelContext           : Total 1 routes, of which 1 are started
2020-04-23 08:51:40.102  INFO 10440 --- [           main] o.a.c.i.e.AbstractCamelContext           : Apache Camel 3.1.0 (CamelContext: FTPClient) started in 0.286 seconds
2020-04-23 08:51:40.111  INFO 10440 --- [           main] e.m.l.m.ApplicationMain                  : Started ApplicationMain in 2.933 seconds (JVM running for 5.057)
2020-04-23 08:51:41.102  WARN 10440 --- [ources%5Csource] .r.RemoteFilePollingConsumerPollStrategy : Trying to recover by force disconnecting from remote server and re-connecting at next poll: ftp://anonymous@localhost:2121
2020-04-23 08:51:41.106  WARN 10440 --- [ources%5Csource] o.a.c.c.f.r.FtpConsumer                  : Consumer FtpConsumer[ftp://localhost:2121/C:%5CUsers%5CJO24447%5Cworkspace%5Cmission_services_camel%5Cmission-services-camel%5Cftp-client%5Csrc%5Cmain%5Cresources%5Csource?separator=Windows] failed polling endpoint: ftp://localhost:2121/C:%5CUsers%5CJO24447%5Cworkspace%5Cmission_services_camel%5Cmission-services-camel%5Cftp-client%5Csrc%5Cmain%5Cresources%5Csource?separator=Windows. Will try again at next poll. Caused by: [org.apache.camel.component.file.GenericFileOperationFailedException - File operation failed: 550 No such directory.
 Cannot change directory to: C:. Code: 550]

org.apache.camel.component.file.GenericFileOperationFailedException: File operation failed: 550 No such directory.
 Cannot change directory to: C:. Code: 550
    at org.apache.camel.component.file.remote.FtpOperations.doChangeDirectory(FtpOperations.java:877) ~[camel-ftp-3.1.0.jar:3.1.0]
    at org.apache.camel.component.file.remote.FtpOperations.changeCurrentDirectory(FtpOperations.java:855) ~[camel-ftp-3.1.0.jar:3.1.0]
    at org.apache.camel.component.file.remote.FtpConsumer.doPollDirectory(FtpConsumer.java:135) ~[camel-ftp-3.1.0.jar:3.1.0]
    at org.apache.camel.component.file.remote.FtpConsumer.pollDirectory(FtpConsumer.java:103) ~[camel-ftp-3.1.0.jar:3.1.0]
    at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:133) ~[camel-file-3.1.0.jar:3.1.0]
    at org.apache.camel.support.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:187) [camel-support-3.1.0.jar:3.1.0]
    at org.apache.camel.support.ScheduledPollConsumer.run(ScheduledPollConsumer.java:106) [camel-support-3.1.0.jar:3.1.0]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_241]
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:1.8.0_241]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access1(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_241]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:1.8.0_241]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_241]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_241]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_241]

FTP 服务器日志:

[ INFO] 2020-04-23 08:53:38,062 [] [127.0.0.1] CREATED
[ INFO] 2020-04-23 08:53:38,063 [] [127.0.0.1] OPENED
[ INFO] 2020-04-23 08:53:38,064 [] [127.0.0.1] SENT: 220 Service ready for new user.

[ INFO] 2020-04-23 08:53:38,065 [] [127.0.0.1] RECEIVED: USER anonymous
[ INFO] 2020-04-23 08:53:38,066 [anonymous] [127.0.0.1] SENT: 331 Guest login okay, send your complete e-mail address as password.

[ INFO] 2020-04-23 08:53:38,067 [anonymous] [127.0.0.1] RECEIVED: PASS 
[ INFO] 2020-04-23 08:53:38,067 [anonymous] [127.0.0.1] Anonymous login success - null
[ INFO] 2020-04-23 08:53:38,068 [anonymous] [127.0.0.1] SENT: 230 User logged in, proceed.

[ INFO] 2020-04-23 08:53:38,068 [anonymous] [127.0.0.1] RECEIVED: TYPE A
[ INFO] 2020-04-23 08:53:38,068 [anonymous] [127.0.0.1] SENT: 200 Command TYPE okay.

[ INFO] 2020-04-23 08:53:38,069 [anonymous] [127.0.0.1] RECEIVED: PWD
[ INFO] 2020-04-23 08:53:38,069 [anonymous] [127.0.0.1] SENT: 257 "/" is current directory.

[ INFO] 2020-04-23 08:53:38,069 [anonymous] [127.0.0.1] RECEIVED: CWD C:\Users\JO24447\workspace\mission_services_camel\mission-services-camel\ftp-client\src\main\resources\source
[ INFO] 2020-04-23 08:53:38,070 [anonymous] [127.0.0.1] SENT: 550 No such directory.

[ INFO] 2020-04-23 08:53:38,070 [anonymous] [127.0.0.1] RECEIVED: MKD C:\Users\JO24447\workspace\mission_services_camel\mission-services-camel\ftp-client\src\main\resources\source
[ INFO] 2020-04-23 08:53:38,071 [anonymous] [127.0.0.1] SENT: 550 No permission to create /C:/Users/JO24447/workspace/mission_services_camel/mission-services-camel/ftp-client/src/main/resources/source.

[ INFO] 2020-04-23 08:53:38,071 [anonymous] [127.0.0.1] RECEIVED: MKD C:
[ INFO] 2020-04-23 08:53:38,072 [anonymous] [127.0.0.1] SENT: 550 No permission to create /C:.

[ INFO] 2020-04-23 08:53:38,072 [anonymous] [127.0.0.1] RECEIVED: MKD C:\Users
[ INFO] 2020-04-23 08:53:38,073 [anonymous] [127.0.0.1] SENT: 550 No permission to create /C:/Users.

[ INFO] 2020-04-23 08:53:38,073 [anonymous] [127.0.0.1] RECEIVED: MKD C:\Users\JO24447
[ INFO] 2020-04-23 08:53:38,073 [anonymous] [127.0.0.1] SENT: 550 No permission to create /C:/Users/JO24447.

[ INFO] 2020-04-23 08:53:38,074 [anonymous] [127.0.0.1] RECEIVED: MKD C:\Users\JO24447\workspace
[ INFO] 2020-04-23 08:53:38,074 [anonymous] [127.0.0.1] SENT: 550 No permission to create /C:/Users/JO24447/workspace.

[ INFO] 2020-04-23 08:53:38,074 [anonymous] [127.0.0.1] RECEIVED: MKD C:\Users\JO24447\workspace\mission_services_camel
[ INFO] 2020-04-23 08:53:38,075 [anonymous] [127.0.0.1] SENT: 550 No permission to create /C:/Users/JO24447/workspace/mission_services_camel.

[ INFO] 2020-04-23 08:53:38,075 [anonymous] [127.0.0.1] RECEIVED: MKD C:\Users\JO24447\workspace\mission_services_camel\mission-services-camel
[ INFO] 2020-04-23 08:53:38,076 [anonymous] [127.0.0.1] SENT: 550 No permission to create /C:/Users/JO24447/workspace/mission_services_camel/mission-services-camel.

[ INFO] 2020-04-23 08:53:38,076 [anonymous] [127.0.0.1] RECEIVED: MKD C:\Users\JO24447\workspace\mission_services_camel\mission-services-camel\ftp-client
[ INFO] 2020-04-23 08:53:38,077 [anonymous] [127.0.0.1] SENT: 550 No permission to create /C:/Users/JO24447/workspace/mission_services_camel/mission-services-camel/ftp-client.

[ INFO] 2020-04-23 08:53:38,077 [anonymous] [127.0.0.1] RECEIVED: MKD C:\Users\JO24447\workspace\mission_services_camel\mission-services-camel\ftp-client\src
[ INFO] 2020-04-23 08:53:38,077 [anonymous] [127.0.0.1] SENT: 550 No permission to create /C:/Users/JO24447/workspace/mission_services_camel/mission-services-camel/ftp-client/src.

[ INFO] 2020-04-23 08:53:38,078 [anonymous] [127.0.0.1] RECEIVED: MKD C:\Users\JO24447\workspace\mission_services_camel\mission-services-camel\ftp-client\src\main
[ INFO] 2020-04-23 08:53:38,078 [anonymous] [127.0.0.1] SENT: 550 No permission to create /C:/Users/JO24447/workspace/mission_services_camel/mission-services-camel/ftp-client/src/main.

[ INFO] 2020-04-23 08:53:38,078 [anonymous] [127.0.0.1] RECEIVED: MKD C:\Users\JO24447\workspace\mission_services_camel\mission-services-camel\ftp-client\src\main\resources
[ INFO] 2020-04-23 08:53:38,079 [anonymous] [127.0.0.1] SENT: 550 No permission to create /C:/Users/JO24447/workspace/mission_services_camel/mission-services-camel/ftp-client/src/main/resources.

[ INFO] 2020-04-23 08:53:38,079 [anonymous] [127.0.0.1] RECEIVED: MKD C:\Users\JO24447\workspace\mission_services_camel\mission-services-camel\ftp-client\src\main\resources\source
[ INFO] 2020-04-23 08:53:38,080 [anonymous] [127.0.0.1] SENT: 550 No permission to create /C:/Users/JO24447/workspace/mission_services_camel/mission-services-camel/ftp-client/src/main/resources/source.

[ INFO] 2020-04-23 08:53:38,080 [anonymous] [127.0.0.1] RECEIVED: CWD /
[ INFO] 2020-04-23 08:53:38,081 [anonymous] [127.0.0.1] SENT: 250 Directory changed to /

[ INFO] 2020-04-23 08:53:39,082 [anonymous] [127.0.0.1] RECEIVED: NOOP
[ INFO] 2020-04-23 08:53:39,083 [anonymous] [127.0.0.1] SENT: 200 Command NOOP okay.

[ INFO] 2020-04-23 08:53:39,083 [anonymous] [127.0.0.1] RECEIVED: PWD
[ INFO] 2020-04-23 08:53:39,084 [anonymous] [127.0.0.1] SENT: 257 "/" is current directory.

[ INFO] 2020-04-23 08:53:39,084 [anonymous] [127.0.0.1] RECEIVED: CWD C:
[ INFO] 2020-04-23 08:53:39,085 [anonymous] [127.0.0.1] SENT: 550 No such directory.

[ INFO] 2020-04-23 08:53:39,086 [anonymous] [127.0.0.1] RECEIVED: QUIT
[ INFO] 2020-04-23 08:53:39,087 [anonymous] [127.0.0.1] SENT: 221 Goodbye.

[ INFO] 2020-04-23 08:53:39,087 [anonymous] [127.0.0.1] CLOSED

涉及到许多组件,其中许多对我来说是新的。出现的几个问题是:

您不能使用带有驱动器号的 windows 样式路径 - 它不是 FTP 标准。所以从路径中删除 c: 前缀。还要注意路径是相对于登录 FTP 服务器的用户的主目录。所以通常你不会有路径或者你有像 /inbox 或 /acme/download 这样的小路径(其中 acme 是客户端名称等)。