ftp任务与ant挂起

时间:2010-09-14 13:13:23

标签: ant

我正在尝试通过ftp中的ftp取出文件,在打印“获取文件”后它会挂起,所以我在ant中启用了调试,我的输出是

[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: [] }

我的代码

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

注意:正常的ftp工作正常。我使用的是Linux 64bit,ant 1.6.5和java 1.6.10

2 个答案:

答案 0 :(得分:2)

看起来一切正常,直到您真正尝试并检索数据。 FTP使用两个通道;一个用于控制,一个用于数据。这很好,直到防火墙拒绝数据连接。 Passive mode试图解决这个问题。您的FTP库是否具有“被动模式”或“PASV”选项?

答案 1 :(得分:0)

Ant FTP任务需要依赖项,必须在类路径上的库才能正常运行。见下面的链接,

http://ant.apache.org/manual/install.html#commons-net

要使用FTP任务,您需要jakarta-oro 2.0.8或更高版本以及commons-net

相关问题