Bug 21635 - AntClassLoader Constructor fails to initialize parent classloader
Summary: AntClassLoader Constructor fails to initialize parent classloader
Status: RESOLVED DUPLICATE of bug 40522
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.5.2
Hardware: All other
: P3 normal (vote)
Target Milestone: ---
Assignee: Ant Notifications List
Depends on:
Reported: 2003-07-16 02:45 UTC by Tim
Modified: 2008-02-22 12:18 UTC (History)
2 users (show)


Note You need to log in before you can comment on or make changes to this bug.
Description Tim 2003-07-16 02:45:25 UTC
In attempting to use custom Ant tasks with Jaxb in then I was unable get the 
correct class loader in the task as method: (Call stack at the end)

public AntClassLoader(Project project, Path classpath,
                      boolean parentFirst) 
        this(null,project, classpath, parentFirst);

does not pass the classloader on to the next constructor.

I changed the call to the following and rebuilt and this fixed my problem:

public AntClassLoader(Project project, Path classpath,
                      boolean parentFirst) 
    this(project.getCoreLoader(), project, classpath, parentFirst);

Call Stack:
AntClassLoader.<init>(Project, Path, boolean) line: 340
Taskdef(Definer).createLoader() line: 275
Taskdef(Definer).execute() line: 151
Taskdef(Task).perform() line: 341
Target.execute() line: 309
Target.performTasks() line: 336
Project.executeTarget(String) line: 1339
Project.executeTargets(Vector) line: 1255

Maybe I am not using ant the way it was designed to be used?

Hope this is helpful, ant is the greatest!
Comment 1 Conor MacNeill 2003-07-17 11:56:58 UTC
If you pass null, AntClassLoader uses its own ClassLoader as the parent loader.
This should be the same as project.getCoreLoader(). Can you let me know what
problem you are having as I'm not sure why the ClassLoader change you suggest
would change anything.
Comment 2 Tim 2003-07-17 17:28:11 UTC
If you have called project.setCoreLoader(coreLoader) where coreLoader is not 
null but a specific loader you wish to be the parent loader then this loader 
however will get discarded in the call outlined below.

this(null,project, classpath, parentFirst);

We are using Ant like a workflow engine inside an app-server and so we need 
certain things that we have from the appservers classloader available in ant 
so I need to pass appservers classloader into ant I am doing this by setting 
it in the project.

Hope this helps a bit?

Comment 3 Jesse Glick 2004-07-16 22:55:57 UTC
See also bug #30161 which could be seen as a by-product of this.
Comment 4 Peter Reilly 2006-09-15 14:32:01 UTC
One needs to do a small number of other things
as well.
I have opened a new bug specifically for coreloader
and will make this a duplicate of that.

*** This bug has been marked as a duplicate of 40522 ***