Return-Path: Delivered-To: apmail-ant-user-archive@www.apache.org Received: (qmail 91983 invoked from network); 26 Sep 2003 12:37:54 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 26 Sep 2003 12:37:54 -0000 Received: (qmail 24400 invoked by uid 500); 26 Sep 2003 12:37:41 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 24362 invoked by uid 500); 26 Sep 2003 12:37:41 -0000 Mailing-List: contact user-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list user@ant.apache.org Received: (qmail 24348 invoked from network); 26 Sep 2003 12:37:41 -0000 Received: from unknown (HELO hotmail.com) (64.4.19.119) by daedalus.apache.org with SMTP; 26 Sep 2003 12:37:41 -0000 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Fri, 26 Sep 2003 05:37:42 -0700 Received: from 193.252.151.41 by lw12fd.law12.hotmail.msn.com with HTTP; Fri, 26 Sep 2003 12:37:42 GMT X-Originating-IP: [193.252.151.41] X-Originating-Email: [datawinner@hotmail.com] From: "Data Winner" To: user@ant.apache.org Bcc: Subject: Re: AW: ant newbie.. FTP not working..NullPointerException Date: Fri, 26 Sep 2003 12:37:42 +0000 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 26 Sep 2003 12:37:42.0284 (UTC) FILETIME=[FA8244C0:01C3842A] X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N thanks Antoine....it worked I inserted the setProject method and it has successfully uploaded the file to the server. Thanx once again. >From: Antoine L�vy-Lambert >Reply-To: "Ant Users List" >To: "Ant Users List" >Subject: AW: ant newbie.. FTP not working..NullPointerException >Date: Fri, 26 Sep 2003 13:24:32 +0200 > >in the implementation of FTP.java in ant 1.5.4 the line 738 is > File file = project.resolveFile(new File(dir, >filename).getPath()); > >therefore you should tie your class myFirstFTP to an ant project (call the >method setProject which your class is inheriting. > >Otherwise, I am not sure whether you need to extend the FTP task of ant to >do what you want, maybe you just need to use it rather than extend it. > >Cheers, > >Antoine > >-----Urspr�ngliche Nachricht----- >Von: Data Winner [mailto:datawinner@hotmail.com] >Gesendet: Freitag, 26. September 2003 12:36 >An: user@ant.apache.org >Betreff: ant newbie.. FTP not working..NullPointerException > > >Hello All >I have to use ant apache api for a java program that performs FTP >operations. I am using apache-ant-1.5.4 and have aslo downloaded the >NetComponents.jar for the ftp class. This jar is included in classpath. >I am succcessfully connecting to the server, but when I call any FTP >method, >I get a NullPointerException. Here is my java code: > >---------------------------------------------------------------------------- >----------------- >package ftptest; >import java.io.*; >import com.oroinc.net.ftp.*; >import org.apache.tools.ant.*; > >public class myFirstFtp extends >org.apache.tools.ant.taskdefs.optional.net.FTP >{ > public static void main(String[] args) > { > myFirstFtp myObj = new myFirstFtp(); > myObj.a(); > } > > public void a() > { > FTPClient ftpClt = new FTPClient(); > > String server="192.168.0.155"; > String loginName="anonymous"; > String pass="abc"; > > try > { > int reply; > ftpClt.connect(server); > System.out.println("Connected to " + server + "."); > reply = ftpClt.getReplyCode(); > > if(!FTPReply.isPositiveCompletion(reply)) > { > ftpClt.disconnect(); > System.err.println("FTP server refused connection."); > System.exit(1); > } > else > { > System.out.println("login is "+ ftpClt.login(loginName,pass)); > System.out.println("connection is "+ ftpClt.isConnected()); > System.out.println("change dir "+ >ftpClt.changeWorkingDirectory("testFtp2")); > > this.sendFile(ftpClt,"C:\\myDir","\\a.txt"); > ftpClt.disconnect(); > } > } > catch(IOException e) > { > if(ftpClt.isConnected()) > { > try > { > ftpClt.disconnect(); > } > catch(IOException f) > { > // do nothing > } > } > System.err.println("Could not connect to server."); > e.printStackTrace(); > System.exit(1); > } > } >} >---------------------------------------------------------------------------- >------------ > >I get the following output: >---------------------------------------------------------------------------- >------------ >Connected to 192.168.0.155. > >login is true > >connection is true > >java.lang.NullPointerException > > at org.apache.tools.ant.taskdefs.optional.net.FTP.sendFile(FTP.java:738) > > at ftptest.myFirstFtp.a(myFirstFtp.java:42) > > at ftptest.myFirstFtp.main(myFirstFtp.java:11) > >change dir true > >Exception in thread "main" >---------------------------------------------------------------------------- >------------------------------ > >Can anyone please help me whats missing in my code? >Thanx. > >_________________________________________________________________ > > >--------------------------------------------------------------------- >To unsubscribe, e-mail: user-unsubscribe@ant.apache.org >For additional commands, e-mail: user-help@ant.apache.org > _________________________________________________________________ Instant message with integrated webcam using MSN Messenger 6.0. Try it now FREE! http://msnmessenger-download.com --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org