Bookmark this site!

2009-02-16

ant ftp task libraries:
jakarta-oro; commons-net

A problem

Update: 6 April 2012 This stopped working again. Adding ant-commons-net-1.7.1.jar to ~/.ant/lib resolved the problem.

My installed version of ant (I presume from Developer Tools) doesn't support the ftp task:

$ which ant
/usr/bin/ant
$ ant -version
Apache Ant version 1.7.0 compiled on August 25 2008
$ ant -diagnostics | grep ftp.*Available
ftp : Not Available (the implementation class is not present)
$

The manual says To use the FTP task, you need jakarta-oro 2.0.8 or later, and commons-net

Sounds simple—just find the right .jar files and put them in ~/.ant/lib

jakarta-oro-2.0.8.jar is easy to find.

commons-net-2.0.jar is also easy to find, as is commons-net-ftp-2.0.jar —but they don't work. For example:

$ ls ~/.ant/lib
commons-net-2.0.jar jakarta-oro-2.0.8.jar
$ /usr/bin/ant -diagnostics | grep ftp.*Avail
ftp : Not Available (the implementation class is not present)
$

ant-commons-net-1.7.1.jar does work with Ant version 1.7.0 — and you can find it if you look.

But there is an easier way...

The solution

Update to Ant version 1.7.1 (I did this from MacPorts with Porticus; Fink also has this version):

$ which ant
/opt/local/bin/ant
$ ant -version
Apache Ant version 1.7.1 compiled on June 27 2008
$ant -diagnostics | grep ftp.*Available
$ ls ~/.ant/lib
$

The MacPorts installation includes the requisite java archives. (I haven't tested the Fink install.)

3 comments:

SteveL said...

Whoever built the Ant distro from Apple didn't have all the optional JAR files to hand, so things like the ssh task wont work even if you add jsch.jar to ~/.ant/lib

The message "the implementation class is not present" means that the class implementing the task is missing. You would need to grab the specific ant- .jar (such as ant-jsch.jar) to use many of these missing tasks,

-SteveL (on the Ant dev team)

Anonymous said...

Getting this to work has been a MAJOR headache but it's actually quite simple.

If you've downloaded the jars and set your $ANT_HOME and done everything else including standing on your head and it still doesn't work then read on.

On my mac 'ant' is a symbolic link to what turns out to be another symbolic link:


eppl:GobangJWS bruno$ which ant
/usr/bin/ant
eppl:GobangJWS bruno$
eppl:GobangJWS bruno$ l /usr/bin/ant
lrwxr-xr-x 1 root wheel 22 Sep 6 11:08 /usr/bin/ant -> /usr/share/ant/bin/ant

No matter what you do, these symbolic links seem to be a problem.

So, try pointing directly to your downloaded ant directory and everything should 'automagically' work:

eppl:GobangJWS bruno$ which ant
/Users/bruno/apache/apache-ant-1.7.1/bin/ant
eppl:GobangJWS bruno$
eppl:GobangJWS bruno$ echo $ANT_HOME
/Users/bruno/apache/apache-ant-1.7.1

enjoy ant,
Bruno

Misha Karpenko said...

Hi!
I try to configure ftp task for ant under my Mac OS X 10.6, and it still doesn't work.
I've installed apache_ant using MacPorts.

Here my envs:
misha-macbook:~ misha$ echo $ANT_HOME
/usr/share/java/ant-1.7.1
misha-macbook:~ misha$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/share/java/ant-1.7.1/bin

Here is ant -diagnostics part:
-------------------------------------------
ANT PROPERTIES
-------------------------------------------
ant.version: Apache Ant version 1.7.1 compiled on September 22 2009
ant.java.version: 1.6
ant.core.lib: /usr/share/java/ant-1.7.1/lib/ant.jar
ant.home: /usr/share/java/ant-1.7.1

-------------------------------------------
ANT_HOME/lib jar listing
-------------------------------------------
ant.home: /usr/share/java/ant-1.7.1
ant-antlr.jar (5748 bytes)
ant-jai.jar (21344 bytes)
ant-jmf.jar (6589 bytes)
ant-junit.jar (93514 bytes)
ant-launcher.jar (12138 bytes)
ant-nodeps.jar (430586 bytes)
ant-swing.jar (6734 bytes)
ant-testutil.jar (14933 bytes)
ant-trax.jar (6877 bytes)
ant.jar (1323007 bytes)
commons-net-2.0.jar (197316 bytes)
commons-net-ftp-2.0.jar (91184 bytes)
jakarta-oro-2.0.8.jar (65261 bytes)
xercesImpl.jar (1223877 bytes)
xml-apis.jar (194354 bytes)

-------------------------------------------
USER_HOME/.ant/lib jar listing
-------------------------------------------
user.home: /Users/misha

-------------------------------------------
Tasks availability
-------------------------------------------
p4reopen : Not Available (the implementation class is not present)
sshexec : Not Available (the implementation class is not present)
wlrun : Not Available (the implementation class is not present)
p4label : Not Available (the implementation class is not present)
p4revert : Not Available (the implementation class is not present)
p4submit : Not Available (the implementation class is not present)
scp : Not Available (the implementation class is not present)
p4change : Not Available (the implementation class is not present)
p4delete : Not Available (the implementation class is not present)
p4integrate : Not Available (the implementation class is not present)
rexec : Not Available (the implementation class is not present)
stlist : Not Available (the implementation class is not present)
telnet : Not Available (the implementation class is not present)
p4sync : Not Available (the implementation class is not present)
p4edit : Not Available (the implementation class is not present)
netrexxc : Not Available (the implementation class is not present)
ftp : Not Available (the implementation class is not present)
p4resolve : Not Available (the implementation class is not present)
starteam : Not Available (the implementation class is not present)
stylebook : Not Available (the implementation class is not present)
stlabel : Not Available (the implementation class is not present)
p4have : Not Available (the implementation class is not present)
jdepend : Not Available (the implementation class is not present)
stcheckin : Not Available (the implementation class is not present)
stcheckout : Not Available (the implementation class is not present)
p4labelsync : Not Available (the implementation class is not present)
ejbc : Not Available (the implementation class is not present)
p4fstat : Not Available (the implementation class is not present)
wlstop : Not Available (the implementation class is not present)
p4counter : Not Available (the implementation class is not present)
p4add : Not Available (the implementation class is not present)
ddcreator : Not Available (the implementation class is not present)
A task being missing/unavailable should only matter if you are trying to use it

If you can, give me a clue please.
Thanks.