ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maciej Zawadzki <>
Subject Classloader problem with Taskdef
Date Sat, 14 Dec 2002 02:18:22 GMT

I am encountering a problem in the following scenario:

I am using <taskdef> with a classpathref and lets say that the 
classpathref pointed to by my taskdef contains the jar file MyJar.jar, 
which contains MyTask.class and MyBaseClass.class as well as some other 
classes (including a classloader).  Now, when my task runs, it uses its 
own classloader to load class MySubClass.class (which extends 
MyBaseClass) from some other location.  But, to load MySubClass.class, 
my class loader needs to obtain a reference to MyBaseClass, which would 
normally be no problem since it could get that probably from the parent 
class loader.  But, when using Ant, I get a NoClassFoundError stating 
that MyBaseClass is not found -- even though my class loader uses the 
current thread context class loader as its parent.

Now, it appears to me that the classloader that is used to load 
MyJar.jar containing MyTask and MyBaseClass never sets itself as the 
current thread context classloader and that is why my class loader can 
not find any of those classes.  Am I right in this?

After looking at the AntClassLoader and doing a search on all of Ant's 
code base, I found that there is only one place where the AntClassLoader 
is being set as the current thread context classloader -- and that is in 
the JUnit task.  I'm not familiar enough with how the taskdef works 
within Ant to feel comfortable with making code changes.  Thus, any help 
here would be greatly appreciated.



To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message