I'm trying to pull out the file through ftp within ant, it get hung with after printing "getting files", so I enabled debug in ant and my output is
[root@LODIVM11SE001 net]# ant -d -f ftp_t.xml
Apache Ant version 1.6.5 compiled on June 2 2005
Buildfile: ftp_t.xml
Adding reference: ant.PropertyHelper
Detected Java version: 1.5 in: /root/jdk1.6.0_10/jre
Detected OS: Linux
Adding reference: ant.ComponentHelper
Setting ro project property: ant.version -> Apache Ant version 1.6.5 compiled on June 2 2005
Setting ro project property: ant.file -> /Test_Framework/tasks/net/ftp_t.xml
Adding reference: ant.projectHelper
Adding reference: ant.parsing.context
Adding reference: ant.targets
parsing buildfile /Test_Framework/tasks/net/ftp_t.xml with URI = file:///Test_Framework/tasks/net/ftp_t.xml
Setting ro project property: ant.project.name -> FTP simple interface - ftp.xml
Adding reference: FTP simple interface - ftp.xml
Setting ro project property: ant.file.FTP simple interface - ftp.xml -> /Test_Framework/tasks/net/ftp_t.xml
Project base dir set to: /Test_Framework/tasks/net
+Target:
+Target: ftpget
Setting project property: ftpServerName -> xxxxx
Setting project property: ftpUser -> xxxxx
Setting project property: ftpPassword -> xxxx
Setting project property: ftpRemoteDir -> /test
Setting project property: ftpRemoteFile -> ReadMe.txt
Setting project property: ftpLocalDir -> /local/test
Attempting to create object of type org.apache.tools.ant.helper.DefaultExecutor
Adding reference: ant.executor
Build sequence for target(s) `ftpget' is [ftpget]
Complete build sequence is [ftpget, ]
ftpget:
[echo] FTP getting 'ReadMe.txt' from '/test' to '/local/test'
[ftp] Opening FTP connection to xxxxx
[ftp] connected
[ftp] logging in to FTP server
[ftp] login succeeded
开发者_开发技巧[ftp] changing the remote directory
[ftp] getting files
Could not load a dependent class (com/sun/media/jai/codec/FileSeekableStream) for type image
Could not load a dependent class (com/jcraft/jsch/UserInfo) for type sshexec
Could not load a dependent class (com/jcraft/jsch/UserInfo) for type scp
Could not load a dependent class (jdepend/xmlui/JDepend) for type jdepend
Could not load a dependent class (junit/framework/Test) for type junit
fileset: Setup scanner in dir /local/test with patternSet{ includes: [ReadMe.txt] excludes: [] }
My code
<target name="ftpget" description="Get file over FTP">
<fail message="Build Abrted! Failed to find property:ftpRemoteFile" unless="ftpRemoteFile"/>
<fail message="Build Abrted! Failed to find property:ftpLocalDir" unless="ftpLocalDir"/>
<echo message="FTP getting '${ftpRemoteFile}' from '${ftpRemoteDir}' to '${ftpLocalDir}'"/>
<ftp action="get"
server="${ftpServerName}"
userid="${ftpUser}"
password="${ftpPassword}"
verbose="true"
remotedir="${ftpRemoteDir}"
skipFailedTransfers="true">
<fileset dir="${ftpLocalDir}">
<include name="${ftpRemoteFile}"/>
</fileset>
</ftp>
Note: Normal ftp is working fine. I'm using Linux 64bit, ant 1.6.5 and java 1.6.10
Looks like everything works fine until you actually try and retrieve the data. FTP uses two channels; one for control and one for data. This works out fine until a firewall denies the data connection. Passive mode attempts to work around this. Does your FTP library work have a 'passive mode', or 'PASV' option?
Ant FTP task has require dependencies, Libraries that must be on classpath for it to function properly. See link below,
http://ant.apache.org/manual/install.html#commons-net
To use the FTP task, you need jakarta-oro 2.0.8 or later, and commons-net
精彩评论