You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Amihai Fuks <am...@telmap.com> on 2005/05/30 17:39:56 UTC

NullPointerException at logout from FTP client [net]

Hi,

Thanks for the fast reply.

We attached our connect and disconnect methods. Please try and see if you can spot a logical error in our code.

public void connect() throws FTPServiceException
{
	try
	{									m_ftpClient.setDefaultTimeout(CONNECTION_TIMEOUT_DEFAULT_MS);
	m_ftpClient.connect(m_serverURL);
	m_ftpClient.setDataTimeout(DATA_TIMEOUT_DEFAULT_MS);
	int reply = m_ftpClient.getReplyCode();
	if(!FTPReply.isPositiveCompletion(reply))
	{
		throw new FTPServiceException("FTP server refused connection");
	}
	if (!m_ftpClient.login(m_userName, m_password))
	{
		m_ftpClient.logout();
		throw new FTPServiceException("FTP server refused login 				operation.");
	}				
	}
	catch (IOException e)
	{
	
		throw new FTPServiceException("FTP server connection/login error");
	}
}

public void disconnect() throws FTPServiceException
{
	try
	{
		if (!m_ftpClient.logout())
		{
			// no need to notify client. 
		}	
		m_ftpClient.disconnect();
	}
	catch (IOException e)
	{
		throw new FTPServiceException("FTP server refused dissconnect");
	}
}


We fall at the if (!m_ftpClient.logout()) line in the disconnect method. This does not happen if we are NOT logged in the FTP (we simulated that...)

Thanks again!!!

-----Original Message-----
From: Mihael Knezevic [mailto:m.knezevic@porta.de] 
Sent: Monday, May 30, 2005 4:00 PM
To: Jakarta Commons Users List
Subject: Spam:Re: [net]

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: 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


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