You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by lassesvestergaard <la...@gmail.com> on 2013/06/23 21:02:28 UTC

Cannot change directory to: ". Code: 550 on FTP component

Hi all.

My first post here.

I have been trying to learn Apache camel for a while now, and I think I get
the basics. Currently I'm working with the FTP component, but there seems to
be a problem. Here is my route:

from("ftp://username@host.com?password=hidden&binary=true").process(
     new Processor() {
            public void process(Exchange exchange) throws Exception {
                System.out.println("bla");
                File body = (File) exchange.getIn().getBody();
                if (body != null) {
                    System.out.println("bli");
                    System.out.println(body.listFiles());
                    System.out.println("blu");
                }
            }
        });

I simply want to consume files and folders from a specific FTP server. In my
testings I, at some point, made a FTP producer instead of a consumer (by
accident :-) ), and thereby I created both new files and folders on the FTP
server. This means that I know the connection is ok, and I can alter the FTP
server. The thing is that I can't get the FTP component fetch files and
folders. I get the following errors:

ilePollingConsumerPollStrategy WARN  Trying to recover by disconnecting from
remote server forcing a re-connect at next poll: ftp://

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

I have been googling around but haven't been able to find a solution yet.

I have Apache Camel 2.11.0 which I got about a week ago, and I use Maven.
I'm just using the default Maven repository that Netbeans 7.3 has
implemented. I'm working on a macbook pro with Mountain Lion, and I don't
know what the FTP server is, because I don't have administrator access to
it.

When I log into the FTP server through Filezilla, I can see that the main
folder is "/", and there are two folders named "bbr" and "power". Each of
the two holds csv files.

I have tried all the varieties of the url I could think of:

username@host.com
username@host.com/
username@host.com//
username@host.com/bbr
username@host.com//bbr
username@host.com//bbr/
username@host.com/bbr/

Do you have any suggestions?



--
View this message in context: http://camel.465427.n5.nabble.com/Cannot-change-directory-to-Code-550-on-FTP-component-tp5734612.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Cannot change directory to: ". Code: 550 on FTP component

Posted by Bengt Rodehav <be...@rodehav.com>.
Just read CAMEL-6309 again and it seems to only apply to producers (should
have remembered that since I reported that JIRA myself). I'm interested in
verifying whether this JIRA issue only applies to sftp or also to ftp. I
know I'm pushing it but could you also check if you can upload files to a
subdirectory? You should specify the subdirectory in the URI.

/Bengt


2013/6/27 Bengt Rodehav <be...@rodehav.com>

> OK - thanks. Seems like CAMEL-6309 does not apply to ftp then - which
> surprised me.
>
> /Bengt
>
>
> 2013/6/26 lassesvestergaard <la...@gmail.com>
>
>> I also log in a root level ("/")
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/Cannot-change-directory-to-Code-550-on-FTP-component-tp5734612p5734794.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>
>

Re: Cannot change directory to: ". Code: 550 on FTP component

Posted by Bengt Rodehav <be...@rodehav.com>.
OK - thanks. Seems like CAMEL-6309 does not apply to ftp then - which
surprised me.

/Bengt


2013/6/26 lassesvestergaard <la...@gmail.com>

> I also log in a root level ("/")
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Cannot-change-directory-to-Code-550-on-FTP-component-tp5734612p5734794.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Cannot change directory to: ". Code: 550 on FTP component

Posted by lassesvestergaard <la...@gmail.com>.
I also log in a root level ("/")



--
View this message in context: http://camel.465427.n5.nabble.com/Cannot-change-directory-to-Code-550-on-FTP-component-tp5734612p5734794.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Cannot change directory to: ". Code: 550 on FTP component

Posted by Bengt Rodehav <be...@rodehav.com>.
OK - thanks for your investigation. I just thought you had hit the same
error I reported - although I used sftp and not ftp. But, I thought the bug
affected ftp as well.

Just one final question: Directly after you log in to the ftp server, what
is your current directory? In my case it is the root directory (a virtual
root directory): "/". This is a prerequisite for the error I reported
(CAMEL-6309).

/Bengt


2013/6/25 lassesvestergaard <la...@gmail.com>

> The code I posted is just the latest for my current project. I have tried
> specifying a specific subdir without recursive=true, and that works. It
> seems that I can't get the actual folders (if I traverse a single folder I
> can't list subfolders, only files). When I use recursive=true it traverses
> down through all sub folders though, and retrieves all files.
>
> Yes, I use 2.11.0
>
> Regards
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Cannot-change-directory-to-Code-550-on-FTP-component-tp5734612p5734776.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Cannot change directory to: ". Code: 550 on FTP component

Posted by lassesvestergaard <la...@gmail.com>.
The code I posted is just the latest for my current project. I have tried
specifying a specific subdir without recursive=true, and that works. It
seems that I can't get the actual folders (if I traverse a single folder I
can't list subfolders, only files). When I use recursive=true it traverses
down through all sub folders though, and retrieves all files.

Yes, I use 2.11.0

Regards



--
View this message in context: http://camel.465427.n5.nabble.com/Cannot-change-directory-to-Code-550-on-FTP-component-tp5734612p5734776.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Cannot change directory to: ". Code: 550 on FTP component

Posted by Bengt Rodehav <be...@rodehav.com>.
OK - you use "recursive=true". I meant specifying a specific subdirectory
without the "recursive=true", e g:

from("ftp://host.com/subdir?password=tiktak&binary=true&consumer.delay=10000<ftp://host.com/?password=tiktak&binary=true&consumer.delay=10000&recursive=true>
")

Does that also work? Are you using Camel 2.11.0?

/Bengt




2013/6/25 lassesvestergaard <la...@gmail.com>

> Hi Bengt.
>
> Yes, I'm able to specify a subfolder in my URI.
> As far as I can see, it works fine as a producer if I specify a subfolder.
>
> What I have ended up doing is:
>
> from("
> ftp://host.com?password=tiktak&binary=true&consumer.delay=10000&recursive=true
> ")
>                 .to("file://inbox");
>         from("file://inbox?recursive=true&idempotent=true")
>                 .process(
>                 new Processor() {
>             @Override
>             public void process(Exchange exchange) throws Exception {
>                 String resourceID="";
>                 JSONArray ja=new JSONArray();
>
>                 GenericFile body = (GenericFile)
> exchange.getIn().getBody();
>                 File f = (File) body.getFile();
>                 try (FileInputStream is = new FileInputStream(f)) {
>                     BufferedReader br = new BufferedReader(new
> InputStreamReader(is));
>
>                     if(f.getName().equals("bbr.csv")){
>                         resourceID="";
>                     }else{
>                         resourceID="";
>                     }
>
>                     String[] headlines=null;
>                     String[] datalines=null;
>                     String strLine;
>                     int i=0;
>                     while ((strLine = br.readLine()) != null) {
>                         if(i==0){
>                             headlines=strLine.split(",");
>                         }else{
>                             datalines=strLine.split(",");
>                             JSONObject jo=new JSONObject();
>                             for (int j=0; j<headlines.length;j++){
>                                 jo.put(headlines[j],datalines[j]);
>                             }
>                             ja.put(jo);
>                         }
>                         i++;
>                     }
>                 }
>
> exchange.getIn().setBody("{\"resource_id\":\""+resourceID+"\", \"records\":
> " + ja.toString() + ",\"method\":\"insert\"}");
>             }
>         }).setHeader("CamelHttpMethod", constant("POST"))
>          .setHeader("Authorization", constant("somenumbers"))
>          .to("http4://somehost");
>
> I havent tested the above code fully yet, but I think it work :-). Anyways,
> this is how I solve my problem, and I just want to show my code, so anyone
> with similar tasks can get inspiration.
>
> Thanks for your quick responses and help guys.
>
> Regards
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Cannot-change-directory-to-Code-550-on-FTP-component-tp5734612p5734725.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Cannot change directory to: ". Code: 550 on FTP component

Posted by lassesvestergaard <la...@gmail.com>.
Hi Bengt.

Yes, I'm able to specify a subfolder in my URI.
As far as I can see, it works fine as a producer if I specify a subfolder.

What I have ended up doing is:

from("ftp://host.com?password=tiktak&binary=true&consumer.delay=10000&recursive=true")
                .to("file://inbox");
        from("file://inbox?recursive=true&idempotent=true")
                .process(
                new Processor() {
            @Override
            public void process(Exchange exchange) throws Exception {
                String resourceID="";
                JSONArray ja=new JSONArray();
                
                GenericFile body = (GenericFile) exchange.getIn().getBody();
                File f = (File) body.getFile();
                try (FileInputStream is = new FileInputStream(f)) {
                    BufferedReader br = new BufferedReader(new
InputStreamReader(is));
                    
                    if(f.getName().equals("bbr.csv")){
                        resourceID="";
                    }else{
                        resourceID="";
                    }
                    
                    String[] headlines=null; 
                    String[] datalines=null; 
                    String strLine;
                    int i=0;
                    while ((strLine = br.readLine()) != null) {
                        if(i==0){
                            headlines=strLine.split(",");
                        }else{
                            datalines=strLine.split(",");
                            JSONObject jo=new JSONObject();
                            for (int j=0; j<headlines.length;j++){
                                jo.put(headlines[j],datalines[j]);
                            }
                            ja.put(jo);
                        }
                        i++;
                    }
                }
               
exchange.getIn().setBody("{\"resource_id\":\""+resourceID+"\", \"records\":
" + ja.toString() + ",\"method\":\"insert\"}");
            }
        }).setHeader("CamelHttpMethod", constant("POST"))
         .setHeader("Authorization", constant("somenumbers"))
         .to("http4://somehost");

I havent tested the above code fully yet, but I think it work :-). Anyways,
this is how I solve my problem, and I just want to show my code, so anyone
with similar tasks can get inspiration.

Thanks for your quick responses and help guys.

Regards



--
View this message in context: http://camel.465427.n5.nabble.com/Cannot-change-directory-to-Code-550-on-FTP-component-tp5734612p5734725.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Cannot change directory to: ". Code: 550 on FTP component

Posted by Bengt Rodehav <be...@rodehav.com>.
I'm glad you got it working. I should probably upgrade to commons-net 3.3
too.

Just one question (to see whether your problem is related to CAMEL-6309):
Does it work if you specify a subfolder in your URI? If so, does it also
work as a producer when you specify a subfolder in the URI?

/Bengt


2013/6/24 lassesvestergaard <la...@gmail.com>

> Hi all.
>
> I managed to get it working by upgrading to commons-net 3.3 (thanks). I
> didn't know how to do this in Maven, but it seems that you just make a
> specific dependency for commons-net in your POM, and then the implicit
> commons-net dependency disappears. I don't know if this also go for making
> a
> specific dependency that has a lower version than the implicit dependency.
>
> All-in-all it seems to work. I have a couple of additional questions
> though:
>
> First of all it seems that the Exchange.getIn().getBody(), in the Process,
> returns a GenericFile, and I can only convert it to FTPFile. How would I go
> about this if I want to have a java.io.File?
>
> I can read in the documentation on FTP2 that I will have better performance
> if I first download files to a local folder, and then read them later. I'm
> not sure how to leverage from this. My suggestion has been to first do:
>
> (from://someFTP).to(file://somefolder);
>
> and then in following lines do:
>
> from(file://somefolder).process(new Process(){someCode});
>
> What I can't figure out is if this is the preferred way of doing it. Any
> suggestions?
>
> A last thing that seems odd to me, is that it looks like the FTP component
> ignores sud folders. I can only see actual files, when I run the code from
> my first post. I cannot traverse my entire file structure. I have tried to
> set recursive=true and stepwise=true. I start from my root folder when
> reading.
>
> Any comment is appreciated
>
> Regards
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Cannot-change-directory-to-Code-550-on-FTP-component-tp5734612p5734682.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Cannot change directory to: ". Code: 550 on FTP component

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Jun 24, 2013 at 11:52 PM, lassesvestergaard
<la...@gmail.com> wrote:
> Hi all.
>
> I managed to get it working by upgrading to commons-net 3.3 (thanks). I
> didn't know how to do this in Maven, but it seems that you just make a
> specific dependency for commons-net in your POM, and then the implicit
> commons-net dependency disappears. I don't know if this also go for making a
> specific dependency that has a lower version than the implicit dependency.
>
> All-in-all it seems to work. I have a couple of additional questions though:
>
> First of all it seems that the Exchange.getIn().getBody(), in the Process,
> returns a GenericFile, and I can only convert it to FTPFile. How would I go
> about this if I want to have a java.io.File?
>

You cannot get the ftp as a java.io.File. That is only for file component.
The ftp component uses the FTPFile type which is from the common net
library (which is the ftp client we use)


> I can read in the documentation on FTP2 that I will have better performance
> if I first download files to a local folder, and then read them later. I'm
> not sure how to leverage from this. My suggestion has been to first do:
>

Yeah if the file is big, then you can download directly to a work directory,
or you can use the new streamDownload option.

> (from://someFTP).to(file://somefolder);
>
> and then in following lines do:
>
> from(file://somefolder).process(new Process(){someCode});
>
> What I can't figure out is if this is the preferred way of doing it. Any
> suggestions?
>
> A last thing that seems odd to me, is that it looks like the FTP component
> ignores sud folders. I can only see actual files, when I run the code from
> my first post. I cannot traverse my entire file structure. I have tried to
> set recursive=true and stepwise=true. I start from my root folder when
> reading.
>
> Any comment is appreciated
>
> Regards
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Cannot-change-directory-to-Code-550-on-FTP-component-tp5734612p5734682.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
www.camelone.org: The open source integration conference.

Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Cannot change directory to: ". Code: 550 on FTP component

Posted by lassesvestergaard <la...@gmail.com>.
Hi all.

I managed to get it working by upgrading to commons-net 3.3 (thanks). I
didn't know how to do this in Maven, but it seems that you just make a
specific dependency for commons-net in your POM, and then the implicit
commons-net dependency disappears. I don't know if this also go for making a
specific dependency that has a lower version than the implicit dependency.

All-in-all it seems to work. I have a couple of additional questions though:

First of all it seems that the Exchange.getIn().getBody(), in the Process,
returns a GenericFile, and I can only convert it to FTPFile. How would I go
about this if I want to have a java.io.File?

I can read in the documentation on FTP2 that I will have better performance
if I first download files to a local folder, and then read them later. I'm
not sure how to leverage from this. My suggestion has been to first do:

(from://someFTP).to(file://somefolder);

and then in following lines do:

from(file://somefolder).process(new Process(){someCode});

What I can't figure out is if this is the preferred way of doing it. Any
suggestions? 

A last thing that seems odd to me, is that it looks like the FTP component
ignores sud folders. I can only see actual files, when I run the code from
my first post. I cannot traverse my entire file structure. I have tried to
set recursive=true and stepwise=true. I start from my root folder when
reading.

Any comment is appreciated

Regards



--
View this message in context: http://camel.465427.n5.nabble.com/Cannot-change-directory-to-Code-550-on-FTP-component-tp5734612p5734682.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Cannot change directory to: ". Code: 550 on FTP component

Posted by Bengt Rodehav <be...@rodehav.com>.
This looks very much like CAMEL-6309 (
https://issues.apache.org/jira/browse/CAMEL-6309). I think it might affect
ftp/ftps in addition to sftp (which was my problem).

If it's the same problem then you can't use subdirectories in you URI if
the ftp home directory (where you end up after login) is "/" or "\".

/Bengt




2013/6/24 Claus Ibsen <cl...@gmail.com>

> Hi
>
> There is a bug in commons-net 3.2. You can downgrade to 3.1 or try the
> new 3.3. release.
>
> On Sun, Jun 23, 2013 at 9:02 PM, lassesvestergaard
> <la...@gmail.com> wrote:
> > Hi all.
> >
> > My first post here.
> >
> > I have been trying to learn Apache camel for a while now, and I think I
> get
> > the basics. Currently I'm working with the FTP component, but there
> seems to
> > be a problem. Here is my route:
> >
> > from("ftp://username@host.com?password=hidden&binary=true").process(
> >      new Processor() {
> >             public void process(Exchange exchange) throws Exception {
> >                 System.out.println("bla");
> >                 File body = (File) exchange.getIn().getBody();
> >                 if (body != null) {
> >                     System.out.println("bli");
> >                     System.out.println(body.listFiles());
> >                     System.out.println("blu");
> >                 }
> >             }
> >         });
> >
> > I simply want to consume files and folders from a specific FTP server.
> In my
> > testings I, at some point, made a FTP producer instead of a consumer (by
> > accident :-) ), and thereby I created both new files and folders on the
> FTP
> > server. This means that I know the connection is ok, and I can alter the
> FTP
> > server. The thing is that I can't get the FTP component fetch files and
> > folders. I get the following errors:
> >
> > ilePollingConsumerPollStrategy WARN  Trying to recover by disconnecting
> from
> > remote server forcing a re-connect at next poll: ftp://
> >
> > org.apache.camel.component.file.GenericFileOperationFailedException: File
> > operation failed: 550 Failed to change directory.
> >
> > I have been googling around but haven't been able to find a solution yet.
> >
> > I have Apache Camel 2.11.0 which I got about a week ago, and I use Maven.
> > I'm just using the default Maven repository that Netbeans 7.3 has
> > implemented. I'm working on a macbook pro with Mountain Lion, and I don't
> > know what the FTP server is, because I don't have administrator access to
> > it.
> >
> > When I log into the FTP server through Filezilla, I can see that the main
> > folder is "/", and there are two folders named "bbr" and "power". Each of
> > the two holds csv files.
> >
> > I have tried all the varieties of the url I could think of:
> >
> > username@host.com
> > username@host.com/
> > username@host.com//
> > username@host.com/bbr
> > username@host.com//bbr
> > username@host.com//bbr/
> > username@host.com/bbr/
> >
> > Do you have any suggestions?
> >
> >
> >
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/Cannot-change-directory-to-Code-550-on-FTP-component-tp5734612.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> www.camelone.org: The open source integration conference.
>
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Email: cibsen@redhat.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>

Re: Cannot change directory to: ". Code: 550 on FTP component

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

There is a bug in commons-net 3.2. You can downgrade to 3.1 or try the
new 3.3. release.

On Sun, Jun 23, 2013 at 9:02 PM, lassesvestergaard
<la...@gmail.com> wrote:
> Hi all.
>
> My first post here.
>
> I have been trying to learn Apache camel for a while now, and I think I get
> the basics. Currently I'm working with the FTP component, but there seems to
> be a problem. Here is my route:
>
> from("ftp://username@host.com?password=hidden&binary=true").process(
>      new Processor() {
>             public void process(Exchange exchange) throws Exception {
>                 System.out.println("bla");
>                 File body = (File) exchange.getIn().getBody();
>                 if (body != null) {
>                     System.out.println("bli");
>                     System.out.println(body.listFiles());
>                     System.out.println("blu");
>                 }
>             }
>         });
>
> I simply want to consume files and folders from a specific FTP server. In my
> testings I, at some point, made a FTP producer instead of a consumer (by
> accident :-) ), and thereby I created both new files and folders on the FTP
> server. This means that I know the connection is ok, and I can alter the FTP
> server. The thing is that I can't get the FTP component fetch files and
> folders. I get the following errors:
>
> ilePollingConsumerPollStrategy WARN  Trying to recover by disconnecting from
> remote server forcing a re-connect at next poll: ftp://
>
> org.apache.camel.component.file.GenericFileOperationFailedException: File
> operation failed: 550 Failed to change directory.
>
> I have been googling around but haven't been able to find a solution yet.
>
> I have Apache Camel 2.11.0 which I got about a week ago, and I use Maven.
> I'm just using the default Maven repository that Netbeans 7.3 has
> implemented. I'm working on a macbook pro with Mountain Lion, and I don't
> know what the FTP server is, because I don't have administrator access to
> it.
>
> When I log into the FTP server through Filezilla, I can see that the main
> folder is "/", and there are two folders named "bbr" and "power". Each of
> the two holds csv files.
>
> I have tried all the varieties of the url I could think of:
>
> username@host.com
> username@host.com/
> username@host.com//
> username@host.com/bbr
> username@host.com//bbr
> username@host.com//bbr/
> username@host.com/bbr/
>
> Do you have any suggestions?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Cannot-change-directory-to-Code-550-on-FTP-component-tp5734612.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
www.camelone.org: The open source integration conference.

Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen