Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-6219

FTPOperations changeCurrentDirectory uses local OS path separator, instead of FTP Server. File upload fails.

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Not A Problem
    • Affects Version/s: 2.10.4
    • Fix Version/s: None
    • Component/s: camel-ftp
    • Labels:
      None
    • Environment:

      Windows 7 with Oracle Java 6 JDK
      Remote vsftpd server on a Redhat based Linux distribution

    • Estimated Complexity:
      Unknown

      Description

      Summary:
      When uploading a single file to a vsftpd server from Windows using a Camel ftp:// endpoint results in a 550 Failed to change directory error.
      Likely because the changeCurrentDirectory() command in FTPOperations doesn't provide the server pathSeparator when compacting the url.

      Recreate:

      • Start a vsftpd server (this likely affects other FTP servers) in a *nix environment.
      • Set log4j properties to TRACE for Camel
      • In Windows, run a simple Java class that includes the following
        ProducerTemplate pt = camelContext.createProducerTemplate();
        pt.sendBody("ftp://user@host/subfolder?fileName=test.file&password=12345678&stepwise=false&separator=UNIX");

      Trace:
      [2013.03.27 14:53:56] [main] TRACE FtpOperations - buildDirectory(test)
      [2013.03.27 14:53:56] [main] TRACE FtpOperations - changeCurrentDirectory(/var/ftp/pub)
      [2013.03.27 14:53:56] [main] TRACE FtpOperations - Changing directory: \var\ftp\pub
      [2013.03.27 14:53:56] [main] WARN RemoteFileProducer - Writing file failed with: File operation failed: 550 Failed to change directory.
      Cannot change directory to: \var\ftp\pub. Code: 550

      As you can see the path swaps from /var/ftp/pub to \var\ftp\pub which is the wrong path separator!

      Likely location:
      org.apache.camel.component.file.remote.FTPOperations:656
      path = FileUtil.compactPath(path);
      org.apache.camel.util.FileUtil:209
      return compactPath(path, File.separatorChar);

      File.separatorChar would return the LOCAL OS path, not the REMOTE OS path.
      This should use the value specified by separator=UNIX ("/" not "\").

      Possible fix would be to use the other compactPath(path,separator) method.

      Result:
      You cannot upload a single file using FTP in this fashion from a Windows client to a vsftpd server on Linux. I'll have to switch to an alternative product for ftp until this is resolved, but look forward to returning to using Camel for FTP uploads in the future

        Activity

        Show
        mark.richards Mark Richards added a comment - Possibly relates to: http://camel.465427.n5.nabble.com/FTP-endpoint-FtpOperation-change-directory-error-tp5502517.html
        Hide
        davsclaus Claus Ibsen added a comment -

        Give the 2.10.5-SNAPSHOT a test as we have fixed bugs in camel-ftp since.

        Show
        davsclaus Claus Ibsen added a comment - Give the 2.10.5-SNAPSHOT a test as we have fixed bugs in camel-ftp since.
        Hide
        markdingram Mark Ingram added a comment -

        This is working for me against 2.10.5-SNAPSHOT, but not in the current 2.12-SNAPSHOT.

        Show
        markdingram Mark Ingram added a comment - This is working for me against 2.10.5-SNAPSHOT, but not in the current 2.12-SNAPSHOT.
        Hide
        rushalias Lu Tahmazyan added a comment - - edited

        I am seeing the same error in 2.11.0 Release.
        Running the FTP client example (src/main/java/org/apache/camel/example/ftp/MyFtpClient.java) shipped with 2.11.0.

        I am getting
        org.apache.camel.component.file.GenericFileOperationFailedException: File operation failed: 550 Failed to change directory.

        FTP server is running Linux Server.
        Client is running on Mac Book Pro.

        Additionally, same code works just fine in 2.10.4 release.

        Show
        rushalias Lu Tahmazyan added a comment - - edited I am seeing the same error in 2.11.0 Release. Running the FTP client example (src/main/java/org/apache/camel/example/ftp/MyFtpClient.java) shipped with 2.11.0. I am getting org.apache.camel.component.file.GenericFileOperationFailedException: File operation failed: 550 Failed to change directory. FTP server is running Linux Server. Client is running on Mac Book Pro. Additionally, same code works just fine in 2.10.4 release.
        Hide
        rushalias Lu Tahmazyan added a comment -

        I think I have identified source of my observed error.

        Apache Camel version 2.11.0 dependes on commons-net-3.2 while 2.10.4 dependes on commons-net-3.1. And it seems commons-net's new implementation of __parsePathname method does not strip quotes from the path.

        Testing with commons-net-3.1, will update shortly.

        Show
        rushalias Lu Tahmazyan added a comment - I think I have identified source of my observed error. Apache Camel version 2.11.0 dependes on commons-net-3.2 while 2.10.4 dependes on commons-net-3.1. And it seems commons-net's new implementation of __parsePathname method does not strip quotes from the path. Testing with commons-net-3.1, will update shortly.
        Hide
        rushalias Lu Tahmazyan added a comment - - edited

        Excluding commons-net-3.2 and replacing it with commons-net-3.1 seems to have fixed it.

        And here is the commons-net bug report: https://issues.apache.org/jira/browse/NET-492

        Show
        rushalias Lu Tahmazyan added a comment - - edited Excluding commons-net-3.2 and replacing it with commons-net-3.1 seems to have fixed it. And here is the commons-net bug report: https://issues.apache.org/jira/browse/NET-492
        Hide
        davsclaus Claus Ibsen added a comment -

        Thanks for testing and discovering this bug in commons net. We will downgrade to 3.1 on trunk and 2.11 branch.

        Show
        davsclaus Claus Ibsen added a comment - Thanks for testing and discovering this bug in commons net. We will downgrade to 3.1 on trunk and 2.11 branch.
        Hide
        davsclaus Claus Ibsen added a comment -

        A problem in commons net 3.1

        Show
        davsclaus Claus Ibsen added a comment - A problem in commons net 3.1

          People

          • Assignee:
            davsclaus Claus Ibsen
            Reporter:
            mark.richards Mark Richards
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development