After some digging through the Ant source, I found that if I don't define
any nested classpath in my taskdef tasks, then the AntClassLoader will not
be used ... So I added my jar to the classpath used to start Ant and removed
the nested classpath to my task definitions ... and it worked ...

However, I would prefer to keep these classpaths in the task definition. If
there is some way to do this, please let me know.

Thanks a lot.
Vincent Massol.

----- Original Message -----
From: "Vincent Massol" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, March 05, 2001 6:41 PM
Subject: Custom Task and classloader problem ?


> Hi,
>
> I have 2 custom tasks defined in my own jar file (package name :
> j2eeunit.ant). I try to call one of my task from the other task.
>
> Here is my task definition in my build.xml
>
>         <taskdef name="startserver"
> classname="j2eeunit.ant.StartServerTask">
>             <classpath>
>                 <pathelement location="lib/j2eeunit-22-0.8.jar"/>
>                 <pathelement path="${java.class.path}"/>
>             </classpath>
>         </taskdef>
>
>         <taskdef name="runservertests"
> classname="j2eeunit.ant.RunServerTestsTask">
>             <classpath>
>                 <pathelement location="lib/j2eeunit-22-0.8.jar"/>
>                 <pathelement path="${java.class.path}"/>
>             </classpath>
>         </taskdef>
>
> Here is the portion of code that I use to call the other task :
>
>         StartServerTask task;
>
>         Object o = project.createTask("startserver");
>         System.out.println("class = " + o.getClass().getName());
>
>         task = (StartServerTask)o;
>
> It fails with a class cast exception .... !
>
> Now, if I bundle my tasks in ant.jar and I removed the taskdefs,
everything
> works fine. It seems it is a classloader problem ...
> Is there a way to solve this ? It seems that the Taskdef task uses the
> AntClassLoader class to load tasks. Is that the problem ? How can I remedy
> it ?
>
> Thanks.
> Vincent Massol.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>

Reply via email to