ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Venkatesh Sangam <>
Subject Re: antlib classloader issue
Date Thu, 04 Nov 2010 18:33:35 GMT
Thank you Mike for your email.

Yes, I have tried using the same "loaderRef", but it does not work. It
complains that the taskdef implementation does not exist. Since the classes
are already loaded, this new taskdef implementation is not added to existing

I was able to use the <classloader> task. This is a custom task written by
JTools <> that lets me
append classpath to an existing classloader. Using  this “classloader” task,
I am able to execute my custom task. This feature was supposed to be part of
ANT_1.8 <>, but I am unable find
official ant manual for this. Do you know of this?


On Wed, Nov 3, 2010 at 8:18 PM, Murray, Mike <> wrote:

> I'm far from an expert in the area of ClassLoaders, but it seems to me
> the only solution is to load your tasks with the same loaderRef that is
> used by the parent, if you can make no changes to the parent.
> -----Original Message-----
> From: Venkatesh Sangam []
> Sent: Wednesday, November 03, 2010 11:44 AM
> To:
> Subject: Re: antlib classloader issue
> I have the following case that is resulting in classcastexception. Any
> suggestion to fix this is really appreciated.
> 1. I have an ant build file parent.xml that has an antlib entry and also
> has usage for the custom tasks defined in the antlib as follows:
>     <taskdef resource="myco/anttasks/antlib.xml"
> uri="antlib:myco.anttasks" loaderRef="myco.custom.tasks.loader">
>        <classpath refid="custom.tasks.class.path"/>
>     </taskdef>
>     <custom:myCustomTypeDef id="my.task"
> xmlns:custom="antlib:myco.anttasks">
>     </custom:myCustomTypeDef>
> The implementation details of myCustomTypeDef are in
> myco/anttasks/antlib.xml
> 2. I have another ant build file child.xml that imports parent.xml and
> defines its own custom tasks. These new custom tasks are an extension to
> the
> tasks already defined in the parent.xml, which means that I need the
> class
> path reference defined in "custom.tasks.class.path"
> 3. When I execute the new task in child.xml, I get a classcastexception
> when referring to myCustomTypeDef. My code does not directly refer
> to myCustomTypeDef, but the parent code that I am extending references
> myCustomTypeDef.
> 4. The classes in the myco/anttasks/antlib.xml are loaded by a different
> classloader than the taskdef in my child.xml and hence I cannot see that
> class.
> How do I resolve this issue? I cannot directly modify parent.xml. Only
> child.xml is in my control. How do I make sure that the taskdef in
> child.xml
> are loaded by the same classloader loading the implementation defined in
> parent antlib.xml
> Thanks, Venkatesh
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message