ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Reilly" <>
Subject Re: Mail failing in build.xml file
Date Tue, 12 Jun 2007 16:07:03 GMT
On 6/11/07, David Weintraub <> wrote:
> I have a very straight forward build.xml file:
> <project name="test" default="test" basedir=".">
>     <target name="test">
>         <mail
>             from=""
>             subject="Test Email"
>             mailhost=""
>             user="dweintraub"
>             password="xxxxxxxx"
>             message="This is a test email"
>             failonerror="true">
>             <to name="David Weintraub"
>                 address=""/>
>         </mail>
>     </target>
> </project>
> When I attempt to execute it, I get the following error message:
> test:
>      [mail] Failed to initialise MIME mail: javax/mail/MessagingException
--- Looking at the source code:
> Which is strange because I set "failonerror" to "true".
This is a bug.
The code does not check the failonerror flag here and simply returns.
>> [mail] Failed to initialise MIME mail: javax/mail/MessagingException
This is due to "helpful" code in EmailTask,  a buildexception is
thrown by classloader utilities -
"Class could not be
loaded because of an invalid dependency." with a cause exception:
 Caused by: java.lang.ClassNotFoundException: javax.mail.MessagingException
however EmailTask#logBuildException() only reports
the message in the cause by exception (javax.mail.MessagingException).

The root cause that can give this exception is a missing
javamail[anyversion].jar file.

you seem to be having problems getting the javamail.jar into
the right place (whatever ANT_HOME/lib that is used by
cruise control ?). Try at the command line.
(NOTE: for linux users, if you installed the jpackage version
of ant, the file /etc/ant.conf will override ANT_HOME for pre ant 1.7.0).

In the mean time, you can use the excellent classloader task
to add the javamail.jar to your project classloader:
   <typedef uri="antlib:net.jtools.classloadertask"

   <cl:classloader loader="project">
       <fileset dir="${user.home}/tools/javamail/" includes="*.jar"/>

   <mail ...>


> Any ideas? I am currently sending mail via CruiseControl and that
> works (and where I got the parameters from) so I know that it is
> possible to send email from this machine.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message