ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claude Vedovini <CVedov...@odyssey-group.com>
Subject RE: Antlib & ClassLoading issues
Date Tue, 04 May 2004 12:36:52 GMT
Hi all,

Diving deeper into Ant's code I might have identified the problem...

First of all the Definer uses the Project.createClassLoader method to get a
ClassLoader in order to lookup the antlib.xml file and further instanciate
the tasks. However, by default, this ClassLoader does not have any parent
and uses the java.class.path sysprop as its path

So I first try adding the project instance's ClassLoader as the parent of
the newly created ClassLoader

However this does not solved the problem...

This is because later on, when lookin'up the antlib.xml using the
getResources method, the AntClassLoader (through the findResources method)
uses its inner class ResourceEnumeration to delegate the lookup but this
Class does not take into account the parent classloader (which is different
from the "normal" parent which is always null).
Thus, only the java.class.path is taken into account when trying to find the
antlib.xml, which obviously only works when in standalone mode.

I additionaly changed the findResource method in AntClassLoader to use a
CompoundEnumeration when a parent has been set and it finally worked :-)

I guess I should enter a bug report...

Cheers,
Claude


> -----Original Message-----
> From: Claude Vedovini [mailto:CVedovini@odyssey-group.com]
> Sent: 4 May 2004 11:29
> To: 'Ant Users List'
> Subject: RE: Antlib & ClassLoading issues
> 
> 
> Hi,
> 
> Actually I tried to modify the code for the <ant> task, 
> initializing the
> coreloader of the called build this does not seems to be enough.
> 
> Thanks for the hint, seems like I used the core loader for 
> nothing since two
> years :-)
> 
> Anyhow, could someone tell me how to set the classloader for the whole
> stuff?
> 
> Thanks in advance,
> Claude
> 
> 
> > -----Original Message-----
> > From: Peter Reilly [mailto:peter.reilly@corvil.com]
> > Sent: 4 May 2004 10:57
> > To: Ant Users List
> > Subject: Re: Antlib & ClassLoading issues
> > 
> > 
> > Hi,
> > I did not know that the coreloader was actually used.
> > See:
> > http://marc.theaimsgroup.com/?l=ant-dev&m=107451990930463&w=2
> > for some discussion on this.
> > 
> > Be that as is may, if the coreloader is in the code, it should be
> > passed to the child projects.
> > 
> > As a work-around, you could trigger the loading of the antlib
> > tasks and types
> > in the initial project: For example add a macro to the
> > antlib : "init"
> > 
> > <macrodef name="init">
> >   <sequential>
> >   </sequential>
> > </macrodef>
> > 
> >  and call it in the initial project:
> > 
> > <project xmlns:s="antlib:com.company.project" default="subs">
> >   <s:init/>
> >   <target name="subs">
> >     <subant ../>
> >   </target>
> > </project>
> > 
> > It may be better to do something like this in any case, 
> > otherwise the tasks/types
> > will be loaded in each of the sub-projects.
> > 
> > Peter
> > 
> > Claude Vedovini wrote:
> > 
> > >I all,
> > >
> > >I am just trying to take advantage of the Antlib feature and 
> > it seems that
> > >in certain circumstances it does not work as expected :-)
> > >
> > >Ok, here is the background:
> > >
> > >We built a nice continuous integration infrastructure using 
> > ant, which is
> > >driven by a web application (our build launcher, currently 
> > running with
> > >Websphere, Weblogic and Tomcat) we also developed some 
> tasks that are
> > >automatically put in the context of the build by our launcher.
> > >Grosso-modo the launcher is a servlet that creates a Project 
> > instance,
> > >configures it and so on.
> > >As you can imagine it also uses the setCoreLoader method to 
> > give the Project
> > >the web-app ClassLoader (which is a non-delegating J2EE 
> ClassLoader).
> > >All this used to work since two years or so...
> > >
> > >Those last days I tried to promote out own tasks to an 
> > Antlib library in
> > >order to take advantage of the namespace stuff and here is 
> > the problem I ran
> > >into:
> > >
> > > - When I declare my antlib: namespace in a "sub" build 
> > (called via the
> > ><ant> task) I got a ClassNotFoundException (and Ant tells me that I
> > >certainly forgot to add a jar in the lib folder)
> > >
> > >I took a look at the <ant> task and it seems that the 
> > CoreLoader of the
> > >calling project (which should further be used to load tasks 
> > I guess) is not
> > >passed through to the called project. Taskdefs are, which 
> > explains why it
> > >was working previously, but as I guess that antlibs are 
> > loaded on request
> > >(when the namespace declaration is met) and using the 
> > project's ClassLoader
> > >then my tasks' classes are no more in the scope.
> > >
> > >I am not 100% sure the problem lies where I think, so if 
> > someone could have
> > >a look (or two) at that issue I think it could help (at 
> least me ;-)
> > >
> > >
> > >Thanks in advance,
> > >Claude
> > >_____________________________________________________________
> > _____________
> > >* This email and any files transmitted with it are 
> > CONFIDENTIAL and intended
> > >solely for the use of the individual or entity to which they 
> > are addressed.
> > >* Any unauthorized copying, disclosure, or distribution of 
> > the material
> > >within
> > >this email is strictly forbidden.
> > >* Any views or opinions presented within this e-mail are 
> > solely those of the
> > >author and do not necessarily represent those of Odyssey 
> > Asset Management
> > >Systems SA unless otherwise specifically stated.
> > >* An electronic message is not binding on its sender.  Any 
> > message referring
> > >to
> > >a binding engagement must be confirmed in writing and duly signed.
> > >* If you have received this email in error, please notify 
> the sender
> > >immediately
> > >and delete the original.
> > >
> > >  
> > >
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
> > 
> ______________________________________________________________
> ____________
> * This email and any files transmitted with it are 
> CONFIDENTIAL and intended
> solely for the use of the individual or entity to which they 
> are addressed.
> * Any unauthorized copying, disclosure, or distribution of 
> the material
> within
> this email is strictly forbidden.
> * Any views or opinions presented within this e-mail are 
> solely those of the
> author and do not necessarily represent those of Odyssey 
> Asset Management
> Systems SA unless otherwise specifically stated.
> * An electronic message is not binding on its sender.  Any 
> message referring
> to
> a binding engagement must be confirmed in writing and duly signed.
> * If you have received this email in error, please notify the sender
> immediately
> and delete the original.
> 
__________________________________________________________________________
* This email and any files transmitted with it are CONFIDENTIAL and intended
solely for the use of the individual or entity to which they are addressed.
* Any unauthorized copying, disclosure, or distribution of the material
within
this email is strictly forbidden.
* Any views or opinions presented within this e-mail are solely those of the
author and do not necessarily represent those of Odyssey Asset Management
Systems SA unless otherwise specifically stated.
* An electronic message is not binding on its sender.  Any message referring
to
a binding engagement must be confirmed in writing and duly signed.
* If you have received this email in error, please notify the sender
immediately
and delete the original.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message