tags:

views:

799

answers:

3

I've been running the built-in Ant from the command line on a Macintosh (10.5.5) and have run into some trouble with the Mail task. Running the Mail task produces the following message:

[mail] Failed to initialise MIME mail: org.apache.tools.ant.taskdefs.email.MimeMailer

This is most likely due to a missing ant-javamail.jar file in the /usr/share/ant/lib directory. I see a "ant-javamail-1.7.0.pom" file in this directory but not the appropriate jar file. Anyone know why this jar file might be missing and what the best way to resolve the problem is?

+2  A: 

Download the Java Mail libraries from: http://java.sun.com/products/javamail/ . You will also need http://java.sun.com/products/javabeans/glasgow/jaf.html

A list of all external dependencies required by Ant's optional tasks are outlined here http://ant.apache.org/manual/index.html .

Another way to get dependencies for Ant very easily, is to run:

ant -f fetch all

from $ANT_HOME. You can also run -projecthelp for a full list of targets:

all         load all the libraries
 antlr       load antlr libraries
 bcel        load bcel libraries
 beanshell   load beanshell support
 bsf         load bsf libraries
 debugging   internal ant debugging
 get-m2      Download the Maven2 Ant tasks
 jdepend     load jdepend libraries
 jruby       load jruby
 junit       load junit libraries
 jython      load jython
 logging     load logging libraries
 networking  load networking libraries (commons-net; jsch)
 regexp      load regexp libraries
 rhino       load rhino
 script      load script languages
 xerces      load an updated version of Xerces
 xml         load full XML libraries (xalan, resolver)
npellow
Unfortunately, the default ant distribution that comes with the Mac doesn't seem to include the fetch.xml file -- so the "ant -f fetch all" command described above will not work.
Ken
That is not good. It may be possible to have ant download the dependencies using ivy and the *.pom in the lib directory.
npellow
A: 

Here's what I ended up doing to resolve the problem:

  1. Downloaded the latest version of Ant from http://ant.apache.org/
  2. The "built-in" Ant is installed in /usr/share/ant; I didn't want to overwrite that version so I extracted the new, full version into /usr/local/share/apache-ant-1.7.1/
  3. As npellow points out, the the Mac doesn't include mail.jar or activation.jar -- these files can be downloaded and extracted from JavaMail API and JavaBeans Activation Framework respectively and copied to the new ant lib folder (same folder as all the ant-*.jar files)
  4. The ant command (/usr/bin/ant) is a symbolic link to /usr/share/ant/bin/ant; I updated this link to point to the new version (ln -s /usr/local/share/apache-ant-1.7.1/bin/ant /usr/bin/ant)

If for some reason you need to make the old version of Ant the default again, just use
ln -s /usr/share/ant/bin/ant /usr/bin/ant

Steps 2-4 were done at the command prompt as root. That's it -- the Mac now has the latest, complete version of Ant and the Mail task works just fine.

Ken
A: 

I also got this working a slightly different way:

  1. Created directory ~/.ant/lib.
  2. Downloaded JavaMail API and copied the jars into that directory.
  3. Downloaded JavaBeans Activation Framework and copied the jars into that directory.
  4. Downloaded Apache Ant 1.7.0 (not the latest, matches the installed version) and copied the apache-ant-1.7.0/lib/ant-javamail.jar file into that directory.

This only solves the problem for a single user account, but that was fine for my purposes and saved me the hassle of having two separate ant installations on my machine.

benzado