ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Conor MacNeill" <>
Subject RE: Reverse class loading undocumented, required and deprecated?
Date Thu, 20 Sep 2001 23:42:11 GMT

In Ant 1.4, I changed the taskdef classloading so that it delegates to the
parent classloader. This is the proper behaviour. I did put a warning into
WHATSNEW about this. If you recall, the old behaviour is the source of
Linkage errors in xml-fop. This behaviour is not always desirable, however,
since factory objects that exist in the system classpath are unable to load
classes in the classpath given to the task classloader. That is what is
happening below. The SAX factory use by Ant's core cannot see the Xerces

I asked Geir to change Velocity so that it did not ask for a specific
parser. This would have made this problem go away and Anakia would have used
Ant's XML parser rather than xerces. That did not happen.

There was another problem with Anakia, however, related to the Velocity
singleton. Basically you can't have two instances of this task when the
velocity classes exist in the system classpath as the singleton gets created
once with the template path and the second instance cannot reset the
template path. IMHO, singletons are evil :-)

So, since it did not appear that Anakia/velocity were going to change, I
relunctantly added a mechanism to access the Ant 1.3 behaviour, so that
these tasks would continue to function, albeit with some effort. I didn't
really want this attribute to become popular. That is also why it is
deprecated. Nevertheless, until Anakia/Velocity are changed, it will be
required to use these tasks.

In truth, classloading has been gradually grafted onto Ant and it shows up
in overlapping classpaths between the Ant core and its tasks. It needs to be
changed but will most easily be achieved in Ant2. We need to clearly define
the classloader hierarchy as has been done in servlet containers.


> -----Original Message-----
> From: Sam Ruby []
> Sent: Friday, 21 September 2001 2:23 AM
> To:
> Subject: Reverse class loading undocumented, required and deprecated?
> I'm describing the scenario below using the released version of 1.4.  It
> applies equally to the latest CVS.  It also represents a change
> in behavior
> from Ant 1.3.
> Test case:
>    Download ant 1.4 distribution.  Unpack.  Set path and ANT_HOME.
>    Checkout jakarta-site2.  Cd into the directory.
>    Execute "ant" with no arguments.
> Results:
>    Buildfile: build.xml
>    prepare:
>    prepare-error:
>    docs:
>       [anakia] Transforming into: D:\jakarta\jakarta-site2\docs
>       [anakia] Error: org.jdom.JDOMException: Error in building:
> SAX2 driver class org.apache.xerces.parsers.SAXParser not found
>    D:\jakarta\jakarta-site2\build.xml:44: org.jdom.JDOMException:
> Error in building: SAX2 driver class
> org.apache.xerces.parsers.SAXParser not found
>    Total time: 2 seconds
> Apply the following patch:
>    Index: build.xml
>    ===================================================================
>    RCS file: /home/cvs/jakarta-site2/build.xml,v
>    retrieving revision 1.7
>    diff -u -r1.7 build.xml
>    --- build.xml   2001/07/27 18:54:01     1.7
>    +++ build.xml   2001/09/20 16:11:53
>    @@ -31,7 +31,7 @@
>         <!-- This Target is for output of HTML pages for the web site -->
>         <target name="docs" depends="prepare-error"
> if="AnakiaTask.present"
>          description="Render HTML Pages via Anakia">
>    -        <taskdef name="anakia"
>    +        <taskdef name="anakia" reverseLoader="true"
>                 classname="org.apache.velocity.anakia.AnakiaTask">
>                 <classpath refid="classpath"/>
>             </taskdef>
> Try again:
>    Buildfile: build.xml
>    prepare:
>    prepare-error:
>    docs:
>      [taskdef] The reverseloader attribute is DEPRECATED. It will
> be removed
>       [anakia] Transforming into: D:\jakarta\jakarta-site2\docs
>       [anakia] Input:  index.xml
>       [anakia] Output: D:\jakarta\jakarta-site2\docs\index.html
> - Sam Ruby

View raw message