2

I have couple days, look around apache Camel and transfer files over sftp server to jms queue or topic.

I faced a problems at a level of configuring an endpoints (consumer) , also routes (from file to sftp, from sftp to jms.....). Nothing works to me. I work on sftp server (linux), java version "1.7.0_45" I use apache camel 2.5, activemq 5.3.2, I uploaded Jsch jar,

this is my simple code

public class FtpJms {

    public static void main(String args[]) throws Exception {
        CamelContext context = new DefaultCamelContext();
        context.addRoutes(new RouteBuilder() {
             @Override
            public void configure() {

            from("file://usr/dir1/dir2?noop=true").
            to("sftp://root@hostname/inbox?username=root&password=xxx");
        }});

I package my program into a jar file, then, I run it on server. However, it returns :

[ - file://usr/dir1/dir2] SftpOperations                 INFO  JSCH -> Authentications that can continue: password
[ - file://usr/dir1/dir2] SftpOperations                 INFO  JSCH -> Next authentication method: password
[ - file://usr/dir1/dir2] SftpOperations                 INFO  JSCH -> Authentication succeeded (password).
[ - file://usr/dir1/dir2] SftpOperations                 INFO  Connected to sftp://root@hostname:22
[ - file://usr/dir1/dir2] RemoteFileProducer             INFO  Connected and logged in to: Endpoint[sftp://root@hostname/inbox?password=******&username=root]
[ - file://usr/dir1/dir2] RemoteFileProducer             WARN  Writing file failed with: Cannot store file: inbox/test10.txt
[ - file://usr/dir1/dir2] SftpOperations                 INFO  JSCH -> Disconnecting from hostname port 22
[ - file://usr/dir1/dir2] GenericFileOnCompletion        ERROR Caused by: [org.apache.camel.component.file.GenericFileOperationFailedException - Cannot store file: inbox/test10.txt]
org.apache.camel.component.file.GenericFileOperationFailedException: Cannot store file: inbox/test10.txt
        at org.apache.camel.component.file.remote.SftpOperations.storeFile(SftpOperations.java:617)[jar:rsrc:camel-ftp-2.5.0.jar!/:]
        at org.apache.camel.component.file.GenericFileProducer.writeFile(GenericFileProducer.java:220)[jar:rsrc:camel-core-2.5.0.jar!/:]
        at org.apache.camel.component.file.GenericFileProducer.processExchange(GenericFileProducer.java:138)[jar:rsrc:camel-core-2.5.0.jar!/:]
        at org.apache.camel.component.file.remote.RemoteFileProducer.process(RemoteFileProducer.java:49)[jar:rsrc:camel-ftp-2.5.0.jar!/:]
        at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:50)[jar:rsrc:camel-core-2.5.0.jar!/:]
Chayma Sakouhi
  • 79
  • 2
  • 10
  • Is that the entire stacktrace? There should be one or more "caused by" secions with additional stack traces. – Kenster Apr 24 '17 at 16:33
  • it is an extract from stack trace. but, it is an example of one rolling/reading file from directory /usr/dir1/dir2 , the successive exception are for the next files. – Chayma Sakouhi Apr 24 '17 at 16:49
  • Well, you can see from the [camel source code](https://github.com/apache/camel/blob/master/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java#L919) that "cannot store file" is a generic error message indicating an exception occurred. The `GenericFileOperationFailedException` should have the original exception attached as a cause. Without the original exception, there's no way to tell exactly why the operation failed. – Kenster Apr 24 '17 at 16:53
  • sorry, I still unable to understand the cause :( – Chayma Sakouhi Apr 24 '17 at 17:04
  • Are you able to upload to the sftp-host manually? – Andriy Slobodyanyk Apr 24 '17 at 20:14
  • Make sure that the user has permission to write to the directory. – Erik Karlstrand Apr 25 '17 at 10:51
  • Is there not more information in that stacktrace? – Claus Ibsen Apr 25 '17 at 13:20
  • Also you can try and test with latest version of Apache Camel as 2.5.0 is a very old release. – Claus Ibsen Apr 25 '17 at 13:20
  • In my case the source file extension was wrong. – Aamir Mar 25 '20 at 12:34

0 Answers0