DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=28782>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=28782 Antlib & ClassLoading issues in J2EE environment Summary: Antlib & ClassLoading issues in J2EE environment Product: Ant Version: 1.6.1 Platform: All OS/Version: All Status: NEW Severity: Normal Priority: Other Component: Core AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] 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:[EMAIL PROTECTED] > 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:[EMAIL PROTECTED] > > 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 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]