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 software developer and architect. Pascal has been designing and building applications since 2001. He is particularly interested in Open Source toolstack (Mule, Spring Framework, JBoss) and technologies like Web Services, SOA and Cloud technologies. Lately he is having great fun by building iOS apps with Swift. Specialties: JEE AWS XML/XSD/XSLT Web Services/SOA Mule ESB/ WSO2 ESB Maven Cloud Technology 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.