Does anynore have any suggestions on the below classloader issue?

Any suggestions are really appreciated

Thanks,
Venkatesh

On Thu, Oct 21, 2010 at 11:37 AM, Venkatesh Sangam <vsan...@gmail.com>wrote:

> Hello,
>
> 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
>
>

Reply via email to