commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hector (JIRA)" <>
Subject [jira] Created: (NET-301) NullPointerException in method SocketClient.getLocalAddress()
Date Wed, 25 Nov 2009 17:28:39 GMT
NullPointerException in method SocketClient.getLocalAddress()

                 Key: NET-301
             Project: Commons Net
          Issue Type: Bug
    Affects Versions: 2.0
         Environment: Sun SPARC Ultra-5, Solaris 8
java version "1.3.1_10"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_10-b03)
Java HotSpot(TM) Client VM (build 1.3.1_10-b03, mixed mode)
            Reporter: Hector


I'm new with Java (well, I have develop some programs, but not so hard....until now) and I'm
trying to create an applet which can open an ftp connection from the client side to the server
one, and download several files (I don't know if it's the best way to do what I want, but
as far as I have read in internet, this is the most common and easy method used by many people).

The problem is about the FTPClient class:
I am able to connect, logon, set transfer mode, change the working directory, list the names
of the directory...but when I try to perform a simple call to the  "retrieveFile (remote,
local)" method, I'm getting a NullPointerException (the call to that method is done after
clicking on a download button):

Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException
	at Applet1.jButton1_actionPerformed(
	at Applet1.access$100(
	at Applet1$3.actionPerformed(
	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at Source)

And the code is very simple:

String reply;    		
boolean success;
String path = new String ("PATH_TO_REMOTE_FILE");
	fich_local = new File (jTextField1.getText () + "/Local_file.txt");
	local_file = new FileOutputStream (fich_local);
	String remote_file = new String (path + "/Remote_file.txt");
	reply = ftp.getReplyString();
	reply = ftp.getReplyString();
	reply = ftp.getReplyString();
	reply = ftp.getReplyString();
	reply = ftp.printWorkingDirectory();
	success = ftp.retrieveFile(remote_file,  local_file);
	System.out.println("Status: " + success + " -- Remote File: " + remote_file + " -- Local
File: " + fich_local.getAbsolutePath ());
catch (FileNotFoundException fnfe)
	fnfe.printStackTrace ();
catch (IOException ioe) 
       	ioe.printStackTrace ();
catch (Exception e)
	e.printStackTrace ();

The remote server, directory and file whithin is included the "Remote_file.txt" exists, and
the print line shows all this info if I catch the "NullPointerException" (also shows a "false"
when calling to the success variable).
I have googled a lot (and still googling), but found almost nothing useful and I would appreciate
a lot any help (also if you need additional info, please let me know).
Thanks in advance

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message