aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes MessagingException with Ant mail task Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "MessagingException with Ant mail task" Watch "MessagingException with Ant mail task" New topic
Author

MessagingException with Ant mail task

kwame Iwegbue
Ranch Hand

Joined: Sep 02, 2000
Posts: 197
I'm having trouble with the Ant mail task. Its giving the error message below.

Buildfile: C:\Java\workspace\hospital\build.xml
init:
zip_dev:
mail_dev:
[mail] Failed to initialise MIME mail: javax/mail/MessagingException
[mail] Sending email: Test build
[mail] Failed to send email

BUILD FAILED
C:\Java\workspace\hospital\build.xml:45: IO error sending mail

Total time: 7 seconds


this is the target:



I have searched on google, and some forums recommned placing mail.jar and activation.jar in %ANT_HOME%/lib which i have already done. (though, I'm using eclipse, so I placed these in /eclipse/plugins/%ANT_HOME%/lib)

please help!!
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
My experience with eclipse is that it doesn't recognize that additional jars have been dropped into the ant home lib directory. You need to change the ant runtime configuration (under windows preferences on my version of eclipse).
kwame Iwegbue
Ranch Hand

Joined: Sep 02, 2000
Posts: 197
Thanks for the reply Carol. Please what exactly should I change in the runtime configuration?
kwame Iwegbue
Ranch Hand

Joined: Sep 02, 2000
Posts: 197
well, I added the jars to Ant Home Entries under Ant Runtime, so now I'm no longer getting Exceptions, but the build still fails:

Buildfile: C:\Java\workspace\hospital\build.xml
init:
mail_dev:
[mail] Sending email: Test build
[mail] Failed to send email

BUILD FAILED
C:\Java\workspace\hospital\build.xml:44: Problem while sending mime mail:

Total time: 22 seconds

I wonder if there's a way to debug this?
Oh is the problem obvious?
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
From the ant having problems? page, among other suggestions such as "read the manual":

Examine Debug Output

If you're still having a problem, the next step is to try and gather additional information about what Ant is doing. Try running Ant with the verbose flag:

ant -verbose

or

ant -v
kwame Iwegbue
Ranch Hand

Joined: Sep 02, 2000
Posts: 197
Finally works!!

Solution: Turns out that with Ant 1.6.5, exterrnal jars should not be placed under %ANT_HOME%\lib.

From Ant manual:

Prior to Ant 1.6, all jars in the ANT_HOME/lib would be added to the CLASSPATH used to run Ant...

...Additional directories to be searched may be added by using the -lib option. The -lib option specifies a search path. Any jars or classes in the directories of the path will be added to Ant's classloader. The order in which jars are added to the classpath is as follows:

* -lib jars in the order specified by the -lib elements on the command line
* jars from ${user.home}/.ant/lib (unless -nouserlib is set)
* jars from ANT_HOME/lib

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: MessagingException with Ant mail task