Reputation: 4719
I am new to Camel.
I read the basics and managed to do simple file to file route. When I tried from file to sftp. It failed.
For testing, I have windows 10 as host os and mint Linux as guest os. I can access from win to linux by sftp client. So I have no issue with the access between host an guest. I tried the following code:
public class App {
public static void main(String[] args) throws Exception {
CamelContext camelContext = new DefaultCamelContext();
try {
camelContext.addRoutes(new FtpRouteBuilder());
camelContext.start();
Thread.sleep(200000);
// do other stuff...
} catch (Exception e) {
System.out.printf("ex: " + e.getMessage());
} finally {
camelContext.stop();
}
}
}
public class FtpRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
try {
from("file:c:/temp/input/")
.to("sftp://sftpuser@192.168.10.54/?password=dev&passiveMode=true");
} catch (Exception ex) {
System.out.printf("ex: " + ex.getMessage());
}
}
}
When I tried this code. I got the following exception:-
Failed to create route route1 at: >>> To[sftp://sftpuser@192.168.10.54/?password=dev&passiveMode=true] <<< in route: Route(route1)[[From[file:c:/temp/input/]] -> [To[sftp://sftp... because of Failed to resolve endpoint: sftp://sftpuser@192.168.10.54/?passiveMode=true&password=dev due to: No component found with scheme: sftp18/11/24 17:50:30 INFO impl.DefaultCamelContext: Apache Camel 2.15.1 (CamelContext: camel-1) uptime 0.296 seconds
What is wrong and how to fix it?
Upvotes: 2
Views: 5108
Reputation: 4719
Thanks to ernest_k for pointing out the missing library. I added:-
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-ftp</artifactId>
<version>2.15.1</version>
</dependency>
public class FtpRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
try{
from("file:c:/temp/input/")
..streamCaching()
.to("sftp://sftpuser@192.168.10.54:/sftpuser/?password=dev");
}catch (Exception ex){
System.out.printf("ex: "+ex.getMessage());
}
}
}
It is fixed and the main point to note that the sftp URI. It works.
Upvotes: 1