1) I have a mimimal batch script ...

setlocal

rem NULL out the classpath, we set this internally
set CLASSPATH=

rem Java Development Kit
set JAVA_HOME=c:\java\jdk1.3.1_01
set PATH=%JAVA_HOME%\bin;%PATH%

rem ANT
set ANT_HOME=c:\java\jakarta-ant-1.4
set PATH=%PATH%;%ANT_HOME%\bin

cmd /c ant atest

endlocal

2) I moved the optional jar out of ants lib directory

3) I have the following target in my build script

  <target name="atest">
    <taskdef name="mimeMail"

classname="org.apache.tools.ant.taskdefs.optional.net.MimeMail">
      <classpath>
        <pathelement location="c:/bea/wlserver6.0/lib/weblogic.jar" />
        <pathelement location="c:/java/jakarta-ant-1.4-optional.jar" />
      </classpath>
    </taskdef>

    <mimeMail message="hello world"
              tolist="blah"
              subject="hello"
              from="blah" />

  </target>


While this obviously does not succeed in sending mail the mimeMail task is
actually invoked as you can see in the output below ...

Buildfile: build.xml

atest:
 [mimeMail] sending email

BUILD FAILED

J:\js\working\xxx\build.xml:613: javax.mail.SendFailedException: Sending
failed;
  nested exception is:
        javax.mail.MessagingException: Could not connect to SMTP host:
localhost, port: 25;
  nested exception is:
        java.net.ConnectException: Connection refused: connect

Total time: 2 seconds

--
Jill

----- Original Message -----
From: "William Ferguson" <[EMAIL PROTECTED]>
To: "'Ant Users List'" <[EMAIL PROTECTED]>
Sent: Monday, December 10, 2001 2:56 PM
Subject: RE: Setting classpath for Taskdef


> > Is ${project} defined and pointing to the right place?
>
> Yes
>
> > Is ${project}/tools/ant/lib/optional.jar" the correct location
> > for where you moved the jar to?
>
> Yes
>
> > Try running your build with -verbose and -debug to see if
> > you can get any more information from that.
>
> Always do - no ehlp there.
>
> How are you invoking Ant?
> Are you using Ant.bat or invoking org.apache.tools.ant.Main directly?
> Do you have optional.jar and j2ee.jar in %ANT_HOME%\lib or have you
> specified them on the Ant command line.
>
> William
>
> >
> > --
> > Jill
> >
> >
> > ----- Original Message -----
> > From: "William Ferguson" <[EMAIL PROTECTED]>
> > To: "'Ant Users List'" <[EMAIL PROTECTED]>
> > Sent: Monday, December 10, 2001 2:27 PM
> > Subject: RE: Setting classpath for Taskdef
> >
> >
> > > The task and the taskdef both have the exact same case 'mimeMail'.
> > >
> > > > -----Original Message-----
> > > > From: Jill Stephenson
> > [mailto:[EMAIL PROTECTED]]
> > > > Sent: Monday, 10 December 2001 14:52
> > > > To: Ant Users List
> > > > Subject: Re: Setting classpath for Taskdef
> > > >
> > > >
> > > > Try changing the name of the taskdef to be all lowercase, it
> > > > seems like the case of the task definition and actual usage of
> > > > the task must match  ...
> > > >
> > > > --
> > > > Jill
> > > >
> > > >
> > > > ----- Original Message -----
> > > > From: "William Ferguson" <[EMAIL PROTECTED]>
> > > > To: "'Ant Users List'" <[EMAIL PROTECTED]>
> > > > Sent: Monday, December 10, 2001 12:29 PM
> > > > Subject: RE: Setting classpath for Taskdef
> > > >
> > > >
> > > > > OK.
> > > > >
> > > > > If I remove optional.jar from %ANT_HOME%\lib but define it
> > > > in the MimeMail
> > > > > taskdef along with J2ee.jar,
> > > > > then Ant can't find the MimeMail task.
> > > > >
> > > > > ie
> > > > >
> > > > > <taskdef name="mimeMail"
> > > > > classname="org.apache.tools.ant.taskdefs.optional.net.MimeMail">
> > > > > <classpath>
> > > > > <pathelement location="${project}/lib/j2ee/j2ee.jar"/>
> > > > > <pathelement location="${project}/tools/ant/lib/optional.jar"/>
> > > > > </classpath>
> > > > > </taskdef>
> > > > >
> > > > > Gives
> > > > >
> > > > > D:\source\main\buildScripts\NightlyBuild.xml:44: taskdef class
> > > > > org.apache.tools.ant.taskdefs.optional.net.MimeMail
> > cannot be found
> > > > >         at
> > > > >
> > > >
> > org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:176)
> > > > >         at
> > > > org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:114)
> > > > >
> > > > > etc
> > > > >
> > > > > But if I define the taskdef for MimeMail as above and
> > don't remove
> > > > > optional.jar from %ANT_HOME%\lib then I get
> > > > >
> > > > >
> > > > > D:\source\main\buildScripts\NightlyBuild.xml:172: Could not
> > > > create task of
> > > > > type: mimeMail due to java.lang.NoClassDefFoundError:
> > > > javax/mail/Address
> > > > >         at
> > org.apache.tools.ant.Project.createTask(Project.java:509)
> > > > >         at
> > > > >
> > > >
> > org.apache.tools.ant.UnknownElement.makeTask(UnknownElement.java:148)
> > > > >         at
> > > > >
> > > > org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElem
> > > > ent.java:83)
> > > > >         at org.apache.tools.ant.Task.perform(Task.java:216)
> > > > >
> > > > >
> > > > > So it wuld seem that Ant definitely requires the
> > optional.jar in its
> > > > > classpath when executed, and can't pick it up from the
> > > > taskdef classpath
> > > > > attribute.
> > > > >
> > > > > It also seems that Ant requires that any libraries that are
> > > > needed by an
> > > > > optional task to also be included in Ant's classpath.
> > > > > Ie these classes can't be specified via the classpath
> > attribute of
> > > > taskdef.
> > > > >
> > > > > So either I'm doing something totally wrong, or the
> > > > classpath attribute
> > > > > doesn't appear to function.
> > > > >
> > > > > William
> > > > >
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Steve Loughran [mailto:[EMAIL PROTECTED]]
> > > > > > Sent: Monday, 10 December 2001 12:55
> > > > > > To: Ant Users List
> > > > > > Subject: Re: Setting classpath for Taskdef
> > > > > >
> > > > > >
> > > > > >
> > > > > > ----- Original Message -----
> > > > > > From: "William Ferguson" <[EMAIL PROTECTED]>
> > > > > > To: "'Ant Users List'" <[EMAIL PROTECTED]>
> > > > > > Sent: Sunday, December 09, 2001 4:32 PM
> > > > > > Subject: RE: Setting classpath for Taskdef
> > > > > >
> > > > > >
> > > > > > > Thanks Eric,
> > > > > > >
> > > > > > > optional.jar is already in %ANT_HOME%\lib and it
> > finds it OK.
> > > > > > > It's just not finding j2ee.jar
> > > > > >
> > > > > > That is because the task in optional.jar is in a different
> > > > > > classloader from
> > > > > > the j2ee jar.
> > > > > >
> > > > > > > If I explicitly add j2ee.jar to the classpath when I
> > > > invoke Ant then
> > > > > > > everything works OK.
> > > > > > > But that is not an optimal solution.
> > > > > >
> > > > > > It is all you get unless you pull optional.jar from ant\lib
> > > > > > and include it
> > > > > > in the classpath you spec for MimeMail.
> > > > > >
> > > > > >
> > > > > > --
> > > > > > To unsubscribe, e-mail:
> > > > > > <mailto:[EMAIL PROTECTED]>
> > > > > > For additional commands, e-mail:
> > > > > > <mailto:[EMAIL PROTECTED]>
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > To unsubscribe, e-mail:
> > > > <mailto:[EMAIL PROTECTED]>
> > > > > For additional commands, e-mail:
> > > > <mailto:[EMAIL PROTECTED]>
> > > > >
> > > >
> > > >
> > > > --------------------------------------------------------------
> > > > ---------------------
> > > >
> > > > The contents of this message are the views of the Author and
> > > > do not necessarily reflect the views of SUNCORP METWAY LTD
> > > > ABN 66 010 831 722.
> > > >
> > > > The content of this e-mail, including attachments is a
> > > > confidential communication between the Suncorp Metway Group
> > > > and the intended addressee. Any unauthorised use of the
> > > > contents is expressly prohibited. If you have received this
> > > > e-mail in error please contact the sender immediately and
> > > > then delete the message and any attachment(s).
> > > >
> > > > http://www.suncorpmetway.com.au
> > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > > > <mailto:[EMAIL PROTECTED]>
> > > > For additional commands, e-mail:
> > > > <mailto:[EMAIL PROTECTED]>
> > > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
> >
>
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to