ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Murray, Mike" <>
Subject RE: antlib classloader issue
Date Thu, 04 Nov 2010 03:18:52 GMT
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
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"/>

     <custom:myCustomTypeDef id="my.task"

The implementation details of myCustomTypeDef are in

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
tasks already defined in the parent.xml, which means that I need the
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

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

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
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:

View raw message