You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Mihael Knezevic <m....@porta.de> on 2005/05/30 15:57:07 UTC

Re: [net]

hi,

first of all: you should put something into the 

FTPClient connection = null;
        
        try
        {
            int reply;
            connection = new FTPClient();
            connection.connect("remotehost"); //put in your server

            // After connection attempt, you should 
            // check the reply code to verify success.
            reply = connection.getReplyCode();

            if(!FTPReply.isPositiveCompletion(reply))
            {
                connection.disconnect();
                throw new IOException("Could not connect to Server: " + 
                        connection.getReplyString());
            }

            boolean success = connection.login("username", "password");

            if (!success) 
            {
                // Error while trying to login
  // some reporting
            }
    else
    {
  // we are logged in
  }
.
.
.
.

that is not exactly the code i'm using but it should point you in the right 
direction. first i would try to get the replycode. if it is an error than 
check the reply string (FTPClient.getReplyString() method).

mk

Am Montag, 30. Mai 2005 16:51 schrieb Amihai Fuks:
> Hi,
> 
> We are using commons-net-1.2.2.jar (happens also with 1.4.0). While running 
the following code:
> try
> {
>  connection.connect();
> }
> catch(FTPServiceException e)
> {
>  e.printStackTrace();
> }
> finally
> {
>  try
>  {
>   connection.disconnect();
>  }
>  catch(FTPServiceException e)
>  {
>   e.printStackTrace();
>  }
> }
> 
> We experience this error:
> 
> FTP server connection/login error
> Exception in thread "Thread-6" java.lang.NullPointerException
>       at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:404)
>       at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:438)
>       at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:487)
>       at org.apache.commons.net.ftp.FTP.quit(FTP.java:699)
>       at org.apache.commons.net.ftp.FTPClient.logout(FTPClient.java:678)
>       
> Does anyone have an idea what the problem might be?
> 
> Thanks
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org