ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Ludwig <mil...@gmx.de>
Subject Re: Mail task with mail.jar & activation.jar out of lib folder
Date Wed, 19 Jan 2011 12:51:24 GMT
Patrick Martin schrieb am 19.01.2011 um 10:31 (+0100):
> 
> Is it possible to use the <mail> task without having activation.jar
> and mail.jar in the ant lib folder?

Well, ant-javamail.jar depends on classes from mail.jar, so that one is
required. Not sure about activation.jar, though. That one will likely be
needed for MIME stuff. If you don't do any, you don't need activation.

The JAR has to be on the classpath when needed. But they don't have to
be in $ANT_HOME/lib. You can also use the -lib command line switch or
put the JAR in ~/.ant/lib.

> <taskdef name="mymail"
> classname="org.apache.tools.ant.taskdefs.email.MimeMailer">

  No public execute() in class
  org.apache.tools.ant.taskdefs.email.MimeMailer

You already found out that should be EmailTask instead.

> D:\tmp\build.xml:7: taskdef A class needed by class
> org.apache.tools.ant.taskdefs.email.MimeMailer cannot be found:
> javax/mail/MessagingException
>  using the classloader AntClassLoader[D:\tmp\a\activation.jar]

Only activation.jar in this classloader. But even when I put all
required JARs into that custom classloader, it fails:

    <path id="mail.path">
        <pathelement location="${ant.home}/lib/ant-javamail.jar" />
        <pathelement location="${javamail.dir}/mail.jar" />
        <fileset dir="${javamail.dir}/lib">
            <include name="**/*.jar"/>
        </fileset>
        <pathelement location="${jlb.dir}/activation.jar" />
    </path>

    <taskdef name="mymail"
        classpathref="mail.path"
        classname="org.apache.tools.ant.taskdefs.email.EmailTask" />

T:\MiLu\mail-jar.xml:25: java.lang.ClassNotFoundException: javax.mail.internet.MimeMessage
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        at org.apache.tools.ant.taskdefs.email.EmailTask.execute(EmailTask.java:452)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:390)
        at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:179)
        at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:82)
        at org.apache.tools.ant.Main.runBuild(Main.java:786)
        at org.apache.tools.ant.Main.startAnt(Main.java:218)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

It seems you have to use the main classloader, not a self-defined one. But I
might be wrong. And even if not, I don't know why. For the experts to clarify.

-- 
Michael Ludwig

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message