Using SFTP Transport in Mule2

The SFTP Transport allows files to be read and written to and from directories over SFTP. It is not a standard transport that is distributed with Mule itself but can be added as an extra project. The project can be found here. However, this isn’t updated for Mule2.2 yet.
Here is how to make it work in Mule2.2:

  • See the installation guide of the project itself
    Make sure you have Maven installed and met the other prerequisites stated at the page.
  • Download the source code from here.

  • Make the code work with Mule 2.2.x
  • To do this open the following files in your favorite editor:

    • /resources/META-INF/mule-sftp.xslt
    • /resources/META-INF/spring.handlers
    • /resources/META-INF/spring.schemas

    In all three files replace ‘2.0’ in the namespaces with ‘2.2’

  • Modify one statement
  • in the class ‘SftpMessageDispatcher’ at line 65 I had to remove the second parameter ‘true’ to make it compile. Not sure what it did but it seems to work without it 😉

    String filename = (String) event.getProperty(SftpConnector.PROPERTY_FILENAME, true);


    String filename = (String) event.getProperty(SftpConnector.PROPERTY_FILENAME);
  • Move the properties file
  • In the new version the properties file is expected in another place, so move the file ‘/resources/META-INF/services/org/mule/providers/’ to ‘/resources/META-INF/services/org/mule/transport/’.

That’s it! You can now build the project (without the supplied tests however) by running mvn deploy -DskipTest=true

To use this transport in your Mule project you need to follow the steps like I described here to add a transport to your Mule application.
Here is my example mule-config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns=""

    <sftp:connector name="sftpConnector" pollingFrequency="500"
    <vm:connector name="internalVM" queueEvents="true"/>

    <model name="main">
        <service name="testComponent">
                <sftp:inbound-endpoint connector-ref="sftpConnector" port="22"
                      host="mule-server" path="bin/" user="pascal" password="pascal"/>
                    <vm:outbound-endpoint path="" connector-ref="internalVM" />

and here is the method in my Java test class:

    public void testService() throws Exception {

        client = getMuleClient();

        MuleMessage m = client.request("vm://", 10000);

        if (m != null) {
            String filename = (String) m.getProperty("originalFilename");

            System.out.println("filename = " + filename);

            Object o = m.getPayload();

            System.out.println("o  = " + o);


So, although I didn’t get the unit test to work, the SFTP transport is usable in Mule if you need it to.

About Pascal Alma

Pascal is a senior IT consultant and has been working in IT since 1997. He is monitoring the latest development in new technologies (Mobile, Cloud, Big Data) closely and particularly interested in Java open source tool stacks, cloud related technologies like AWS and mobile development like building iOS apps with Swift. Specialties: Java/JEE/Spring Amazon AWS API/REST Big Data Continuous Delivery Swift/iOS
This entry was posted in Mule and tagged . Bookmark the permalink.

2 Responses to Using SFTP Transport in Mule2

  1. shane says:

    Are you saying you were unable to get this to work?

  2. Pascal Alma says:

    Hi Shane,

    What I said was that I did got it working, except for the unit tests that are supplied in the transport. But by building the Maven component with -Dtest.skip=true it builds fine and works like a charm in my situation.

Comments are closed.