'ftp file upload with camel

i'm trying to upload file via ftp using camel. My code is the following

public static void main(String... args) throws Exception {
    CamelContext context = new DefaultCamelContext();

    context.addRoutes(new RouteBuilder() {
        @Override
        public void configure() {
             from("file:src/data?noop=true").to("ftp://myftp.com/ftp-test/?username=drauxxx&password=mypassword");
        }
    });
    context.start();
    Thread.sleep(10000);
    context.stop();
}

It connects fine but (as you can see in the log ) but when i'm trying to store i get this error:

[1) thread #1 - file://src/data] FileConsumer                   DEBUG Took 0.003 seconds to poll: src/data
[1) thread #1 - file://src/data] FileConsumer                   DEBUG Total 1 files to consume
[1) thread #1 - file://src/data] FileConsumer                   DEBUG About to process file: GenericFile[ReadMe.txt] using exchange: Exchange[ReadMe.txt]
[1) thread #1 - file://src/data] SendProcessor                  DEBUG >>>> Endpoint[ftp://drxxx.com/ftp-test/?password=******&username=drau9546] Exchange[ReadMe.txt]
[1) thread #1 - file://src/data] RemoteFileProducer             DEBUG Not already connected/logged in. Connecting to: Endpoint[ftp://drxxx.com/ftp-test/?password=******&username=drau9546]
[1) thread #1 - file://src/data] RemoteFileProducer             INFO  Connected and logged in to: Endpoint[ftp://drxxx.com/ftp-test/?password=******&username=drau9546]
[1) thread #1 - file://src/data] GenericFileConverter           DEBUG Read file src/data/ReadMe.txt (no charset)
[                          main] DefaultCamelContext            INFO  Apache Camel 2.10.0 (CamelContext: camel-1) is shutting down
[                          main] DefaultShutdownStrategy        INFO  Starting to graceful shutdown 1 routes (timeout 300 seconds)
[                          main] DefaultExecutorServiceManager  DEBUG Created new ThreadPool for source: org.apache.camel.impl.DefaultShutdownStrategy@77addb59 with name: ShutdownTask. -> org.apache.camel.util.concurrent.RejectableThreadPoolExecutor@bdccedd
[el-1) thread #2 - ShutdownTask] DefaultShutdownStrategy        DEBUG There are 1 routes to shutdown
[el-1) thread #2 - ShutdownTask] DefaultShutdownStrategy        DEBUG Route: route1 suspended and shutdown deferred, was consuming from: Endpoint[file://src/data?noop=true]
[el-1) thread #2 - ShutdownTask] DefaultShutdownStrategy        INFO  Waiting as there are still 2 inflight and pending exchanges to complete, timeout in 300 seconds.
[el-1) thread #2 - ShutdownTask] DefaultShutdownStrategy        INFO  Waiting as there are still 2 inflight and pending exchanges to complete, timeout in 299 seconds.
....

[1) thread #1 - file://src/data] RemoteFileProducer             WARN  Writing file failed with: Error writing file [ftp-test/ReadMe.txt]
[1) thread #1 - file://src/data] RemoteFileProducer             DEBUG Disconnecting from: Endpoint[ftp://drxxx.com/ftp-test/?password=******&username=drau9546]
[1) thread #1 - file://src/data] DefaultErrorHandler            DEBUG Failed delivery for (MessageId: ID-raccoonix-55914-1347631981229-0-1 on ExchangeId: ID-raccoonix-55914-1347631981229-0-2). On delivery attempt: 0 caught: org.apache.camel.component.file.GenericFileOperationFailedException: Error writing file [ftp-test/ReadMe.txt]
[1) thread #1 - file://src/data] GenericFileOnCompletion        DEBUG Done processing file: GenericFile[ReadMe.txt] using exchange: Exchange[ReadMe.txt]
[1) thread #1 - file://src/data] GenericFileOnCompletion        WARN  Rollback file strategy: org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy@2c31f2a7 for file: GenericFile[ReadMe.txt]
[1) thread #1 - file://src/data] FileUtil                       DEBUG Retrying attempt 0 to delete file: /home/andrea/workspace/transfer/src/data/ReadMe.txt.camelLock
[1) thread #1 - file://src/data] FileUtil                       DEBUG Tried 1 to delete file: /home/andrea/workspace/transfer/src/data/ReadMe.txt.camelLock with result: true
[1) thread #1 - file://src/data] DefaultErrorHandler            ERROR Failed delivery for (MessageId: ID-raccoonix-55914-1347631981229-0-1 on ExchangeId: ID-raccoonix-55914-1347631981229-0-2). Exhausted after delivery attempt: 1 caught: org.apache.camel.component.file.GenericFileOperationFailedException: Error writing file [ftp-test/ReadMe.txt]

Are there some specific parameters to for a correct file transfer? Is a ftp server related problem?



Solution 1:[1]

Try

from("file:src/data?noop=true").to("ftp://[email protected]/ftp-test/?password=mypassword");

Remove

context.stop();

as it's an experimental code, you don't need it.

Also check The user right of the FTP User, that you are connecting with.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1