I installed the dependencies for the FTP Task in ANT this morning and when I ran the ANT task I promptly got this error:
Could not create type ftp due to java.lang.NoClassDefFoundError: org/apache/commons/net/ftp/FTPClientConfig
Clearly, this means the FTP Client Config class was not where it was supposed to be. I thought I was doing the right thing by downloading http://commons.apache.org/downloads/download_net.cgi and http://jakarta.apache.org/site/downloads/downloads_oro.cgi, unzipping them into $FlexBuilderHome$/plugins/org.apache.ant_1.7.0.xxxxx/lib directory, then restarting Flex Builder.
It turns out, the ANT thingy in Flex Builder does not read its lib directory each time. Thus, the .jar files were not noticed and registered EVEN THOUGH the ANT administration in Flex Builder registered the files. So, for those following at home, or who found this page by googling the error message above, here are the correct steps to add the .jar files to enable the FTP ANT task in Flex Builder 3 (or eclipse 3.x for that matter):
- Sacrifice a small chicken (optional)
- Download Apache Net Commons, unzip and stick the .jar file in $FlexBuilderHome$/plugins/org.apache.ant_1.7.0.xxxxx/lib
- Download Apache ORO, unzip and stick the .jar file in $FlexBuilderHome$/plugins/org.apache.ant_1.7.0.xxxxx/lib
- In Flex Builder go to Window > Preferences > ANT > Runtime, select the classpath pane, highlight ANT Home Entries and press the Add External JARs button, find the jar for commons, (mine was commons-net-1.4.1.jar ) press open. (If you get a warning screen complaining about a missing tools.jar file, select “Yes” to ignore this. It won’t affect us at all.
- Do the exact same for the ORO .jar file (mine was named jakarta-oro-2.0.8.jar)
- Run your ANT FTP task. If it still doesn’t work, restart Flex Builder.
There is a lot you can do with the ANT FTP task. For some really cool info and good ideas/articles, visit the ANT Wiki maintained by Jim Priest.