[net]

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[net]

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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [net]

Knezevic, Mihael
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: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [net]

Knezevic, Mihael
In reply to this post by Amihai Fuks
fist of all: put something into your mail subject

then, i was i little bit too fast with my reply. your error lies somewhere in
the disconnect method.

the ftpclient object tries to logout, but i can't see a line where you log in.
might be the problem.

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: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]