You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Peter Lynch <pe...@pub.missioncap.ca> on 2005/09/23 21:49:45 UTC

[M2] Plugin Classloaders

Sorry this may be old news but, but I am wondering if Maven 2 has plugin 
classloader seperation to avoid this? I'm scared of what the answer 
might be ;)

-Peter

Brett Porter wrote:
> I don't think this is a specific bug as much as it might be a weird
> combination of dependencies that clash. We'll see. Plugin classloader
> separation would probably fix it (but break most everything else that
> assumes all those dependencies are laying around in one classloader :)
> 
> - Brett
> 
> 
> On Wed, 22 Sep 2004 14:55:54 +0200, Eric Pugh <ep...@upstate.com> wrote:
> 
>>Brett,
>>
>>I like seeing a bug that I thought was going to end up on my plate on
>>someone elses!  If I can help test this, let me know..  I have had some icky
>>problems in the past with changing around the template used by the CC
>>plugin, but this specific bug isn't something I ever had..
>>
>>Eric
>>
>>
>>
>>
>>>-----Original Message-----
>>>From: Brett Porter [mailto:brett.porter@gmail.com]
>>>Sent: Wednesday, September 22, 2004 1:59 PM
>>>To: Maven Users List
>>>Subject: Re: cruisecontrol:configure
>>>
>>>
>>>MAVEN.
>>>
>>>Thanks
>>>
>>>
>>>On Wed, 22 Sep 2004 13:56:45 +0200,
>>>nicolas.chalumeau@arsoe-trelaze.com
>>><ni...@arsoe-trelaze.com> wrote:
>>>
>>>>In the MPCRUISECONTROL or MAVEN jira module ?
>>>>
>>>>Brett Porter <br...@gmail.com>
>>>>22/09/2004 12:36
>>>>Veuillez répondre à "Maven Users List"
>>>>
>>>>        Pour :  Maven Users List <us...@maven.apache.org>
>>>>        cc :
>>>>        Objet : Re: cruisecontrol:configure
>>>>
>>>>
>>>>
>>>>
>>>>classpath issue. Please post this to JIRA with maven --info output.
>>>>
>>>>- Brett
>>>>
>>>>On Wed, 22 Sep 2004 10:12:13 +0200,
>>>>nicolas.chalumeau@arsoe-trelaze.com
>>>><ni...@arsoe-trelaze.com> wrote:
>>>>
>>>>>I use cc 2.1.6 with the the 1.5 plugin. It seem I have a probleme with
>>>>
>>>>the
>>>>
>>>>>jsl:template tag. I try by setting the properties
>>>>
>>>>maven.cruisecontrol.template=cruisecontrol or use it with the default
>>>>value but there is no change
>>>>
>>>>>allways the same message.
>>>>>I probally forgot to set some properties or don't set them
>>>
>>>with correct
>>>
>>>>>value.
>>>>>
>>>>>[Propri\351taire@draken ...maven-struts-module-plugin/]$ maven
>>>>>cruisecontrol:configure
>>>>> __  __
>>>>>|  \/  |__ _Apache__ ___
>>>>>| |\/| / _` \ V / -_) ' \  ~ intelligent projects ~
>>>>>|_|  |_\__,_|\_/\___|_||_|  v. 1.0
>>>>>
>>>>>build:start:
>>>>>
>>>>>scm:parse-connection:
>>>>>    [echo] Using connection:
>>>>>
>>>>
>>>scm:cvs:pserver:nicolas@cvs.codeczar.com:/usr/ngasi/contexts/codec
>>>zar/cvs:maven-struts-module-plugin
>>>
>>>>>Using SCM method: cvs
>>>>>Using CVSROOT:
>>>>>:pserver:nicolas@cvs.codeczar.com:/usr/ngasi/contexts/codeczar/cvs
>>>>>Using module: maven-struts-module-plugin
>>>>>
>>>>>BUILD FAILED
>>>>>File...... C:\Documents and
>>>>>
>>>>
>>>Settings\PropriÚtaire\.maven\cache\maven-cruisecontrol-plugin-1.5\
>>>plugin.jelly
>>>
>>>>>Element... j:include
>>>>>Line...... 72
>>>>>Column.... 51
>>>>>file:C:/Documents and
>>>>>
>>>>
>>>Settings/PropriÚtaire/.maven/cache/maven-cruisecontrol-plugin-1.5/
>>>plugin-resources/cruisecontrol.jsl:30:52:
>>>
>>>>><jsl:template
>>>>> > Property 'match' has no write method
>>>>>Total time: 4 seconds
>>>>>Finished at: Wed Sep 22 20:56:03 GMT+01:00 2004
>>>>>
>>>>>So if some one have any idea ...
>>>>>
>>>>>I solve it temporary by comment the jsl:template tag in the
>>>>
>>>>cruisecontrol.jsl but it is a very bad thing
>>>>
>>>>>Nicolas
>>>>>
>>>>>---------------------------------------------------------------------
>>>>>To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>>>For additional commands, e-mail: users-help@maven.apache.org
>>>>>
>>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>>For additional commands, e-mail: users-help@maven.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>>For additional commands, e-mail: users-help@maven.apache.org
>>>>
>>>>
>>>
>>>---------------------------------------------------------------------
>>
>>
>>>To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>For additional commands, e-mail: users-help@maven.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: [M2] Plugin Classloaders

Posted by Kris Nuttycombe <Kr...@noaa.gov>.
Brett Porter wrote:
> To add a bit of detail for a volunteer to submit as documentation... :)
>
> m2/core/boot is what is in the java classpath (ie, just classworlds,
> which constructs classloaders for the rest of the system)
>
> the top level classloader contains plexus container and plexus utils
> (see m2/core), and also has access to classworlds
>
> the next classloader has the libraries in m2/lib (a bug in beta 1
> incorporated commons-logging and -lang, sorry about that!) In general
> these are just maven libraries. We hope to further separate these in
> future to just be maven apis.
>
> after that, each plugin has its own classloader, including its
> dependencies, itself, and the libraries above. It *does not* contain
> the project dependencies like in m1, but instead has access to a list
> of JAR files in case they are needed.
>
> In addition, a project can list "extensions". These are loaded into
> the same place as m2/lib and so available to the maven core and all
> plugins for the currnet project and subsequent projects (in future, we
> plan to remove it from subsequent projects).
>
> - Brett
So, if one is developing a plugin, what is the appropriate strategy to
take if you want to make the project's artifact (or an intermediate
stage thereof, like the target/classes directory) available to that
plugin? I've tried the following (this is in the execute() method of my
Mojo):

            URL[] urls = { classesDirectory.toURL() };
            ClassLoader originalContextClassLoader =
Thread.currentThread().getContextClassLoader();
            URLClassLoader executionClassLoader = new
URLClassLoader(urls, ClassLoader.getSystemClassLoader());
           
            //enable the new classloader, execute, then restore the old
classloader
           
Thread.currentThread().setContextClassLoader(executionClassLoader);
            this.exec();
           
Thread.currentThread().setContextClassLoader(originalContextClassLoader);

I know that I'm getting the URL to target/classes correctly, but I'm
still getting ClassNotFoundException when my exec() method goes to load
one of those classes.

Any ideas? I've also tried replacing line 3 with:

            URLClassLoader executionClassLoader = new
URLClassLoader(urls, originalContextClassLoader);

without success.

Thanks for your help,

Kris




Re: [M2] Plugin Classloaders

Posted by Brett Porter <br...@gmail.com>.
To add a bit of detail for a volunteer to submit as documentation... :)

m2/core/boot is what is in the java classpath (ie, just classworlds,
which constructs classloaders for the rest of the system)

the top level classloader contains plexus container and plexus utils
(see m2/core), and also has access to classworlds

the next classloader has the libraries in m2/lib (a bug in beta 1
incorporated commons-logging and -lang, sorry about that!) In general
these are just maven libraries. We hope to further separate these in
future to just be maven apis.

after that, each plugin has its own classloader, including its
dependencies, itself, and the libraries above. It *does not* contain
the project dependencies like in m1, but instead has access to a list
of JAR files in case they are needed.

In addition, a project can list "extensions". These are loaded into
the same place as m2/lib and so available to the maven core and all
plugins for the currnet project and subsequent projects (in future, we
plan to remove it from subsequent projects).

- Brett

On 9/24/05, Jason van Zyl <ja...@maven.org> wrote:
> On Fri, 2005-09-23 at 16:49 -0300, Peter Lynch wrote:
> > Sorry this may be old news but, but I am wondering if Maven 2 has plugin
> > classloader seperation to avoid this? I'm scared of what the answer
> > might be ;)
>
> In m2 plug-ins are actually executed from their own Plexus child
> container which has its own classloader. We have sometimes had problems
> with libraries that are needed by Maven itself but for things like
> commons-foo different versions used by different plug-ins should, in
> theory, be Just Fine(tm). :-)
>
>
>
> > -Peter
> >
> > Brett Porter wrote:
> > > I don't think this is a specific bug as much as it might be a weird
> > > combination of dependencies that clash. We'll see. Plugin classloader
> > > separation would probably fix it (but break most everything else that
> > > assumes all those dependencies are laying around in one classloader :)
> > >
> > > - Brett
> > >
> > >
> > > On Wed, 22 Sep 2004 14:55:54 +0200, Eric Pugh <ep...@upstate.com> wrote:
> > >
> > >>Brett,
> > >>
> > >>I like seeing a bug that I thought was going to end up on my plate on
> > >>someone elses!  If I can help test this, let me know..  I have had some icky
> > >>problems in the past with changing around the template used by the CC
> > >>plugin, but this specific bug isn't something I ever had..
> > >>
> > >>Eric
> > >>
> > >>
> > >>
> > >>
> > >>>-----Original Message-----
> > >>>From: Brett Porter [mailto:brett.porter@gmail.com]
> > >>>Sent: Wednesday, September 22, 2004 1:59 PM
> > >>>To: Maven Users List
> > >>>Subject: Re: cruisecontrol:configure
> > >>>
> > >>>
> > >>>MAVEN.
> > >>>
> > >>>Thanks
> > >>>
> > >>>
> > >>>On Wed, 22 Sep 2004 13:56:45 +0200,
> > >>>nicolas.chalumeau@arsoe-trelaze.com
> > >>><ni...@arsoe-trelaze.com> wrote:
> > >>>
> > >>>>In the MPCRUISECONTROL or MAVEN jira module ?
> > >>>>
> > >>>>Brett Porter <br...@gmail.com>
> > >>>>22/09/2004 12:36
> > >>>>Veuillez répondre à "Maven Users List"
> > >>>>
> > >>>>        Pour :  Maven Users List <us...@maven.apache.org>
> > >>>>        cc :
> > >>>>        Objet : Re: cruisecontrol:configure
> > >>>>
> > >>>>
> > >>>>
> > >>>>
> > >>>>classpath issue. Please post this to JIRA with maven --info output.
> > >>>>
> > >>>>- Brett
> > >>>>
> > >>>>On Wed, 22 Sep 2004 10:12:13 +0200,
> > >>>>nicolas.chalumeau@arsoe-trelaze.com
> > >>>><ni...@arsoe-trelaze.com> wrote:
> > >>>>
> > >>>>>I use cc 2.1.6 with the the 1.5 plugin. It seem I have a probleme with
> > >>>>
> > >>>>the
> > >>>>
> > >>>>>jsl:template tag. I try by setting the properties
> > >>>>
> > >>>>maven.cruisecontrol.template=cruisecontrol or use it with the default
> > >>>>value but there is no change
> > >>>>
> > >>>>>allways the same message.
> > >>>>>I probally forgot to set some properties or don't set them
> > >>>
> > >>>with correct
> > >>>
> > >>>>>value.
> > >>>>>
> > >>>>>[Propri\351taire@draken ...maven-struts-module-plugin/]$ maven
> > >>>>>cruisecontrol:configure
> > >>>>> __  __
> > >>>>>|  \/  |__ _Apache__ ___
> > >>>>>| |\/| / _` \ V / -_) ' \  ~ intelligent projects ~
> > >>>>>|_|  |_\__,_|\_/\___|_||_|  v. 1.0
> > >>>>>
> > >>>>>build:start:
> > >>>>>
> > >>>>>scm:parse-connection:
> > >>>>>    [echo] Using connection:
> > >>>>>
> > >>>>
> > >>>scm:cvs:pserver:nicolas@cvs.codeczar.com:/usr/ngasi/contexts/codec
> > >>>zar/cvs:maven-struts-module-plugin
> > >>>
> > >>>>>Using SCM method: cvs
> > >>>>>Using CVSROOT:
> > >>>>>:pserver:nicolas@cvs.codeczar.com:/usr/ngasi/contexts/codeczar/cvs
> > >>>>>Using module: maven-struts-module-plugin
> > >>>>>
> > >>>>>BUILD FAILED
> > >>>>>File...... C:\Documents and
> > >>>>>
> > >>>>
> > >>>Settings\PropriÚtaire\.maven\cache\maven-cruisecontrol-plugin-1.5\
> > >>>plugin.jelly
> > >>>
> > >>>>>Element... j:include
> > >>>>>Line...... 72
> > >>>>>Column.... 51
> > >>>>>file:C:/Documents and
> > >>>>>
> > >>>>
> > >>>Settings/PropriÚtaire/.maven/cache/maven-cruisecontrol-plugin-1.5/
> > >>>plugin-resources/cruisecontrol.jsl:30:52:
> > >>>
> > >>>>><jsl:template
> > >>>>> > Property 'match' has no write method
> > >>>>>Total time: 4 seconds
> > >>>>>Finished at: Wed Sep 22 20:56:03 GMT+01:00 2004
> > >>>>>
> > >>>>>So if some one have any idea ...
> > >>>>>
> > >>>>>I solve it temporary by comment the jsl:template tag in the
> > >>>>
> > >>>>cruisecontrol.jsl but it is a very bad thing
> > >>>>
> > >>>>>Nicolas
> > >>>>>
> > >>>>>---------------------------------------------------------------------
> > >>>>>To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > >>>>>For additional commands, e-mail: users-help@maven.apache.org
> > >>>>>
> > >>>>>
> > >>>>
> > >>>>---------------------------------------------------------------------
> > >>>>To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > >>>>For additional commands, e-mail: users-help@maven.apache.org
> > >>>>
> > >>>>
> > >>>>
> > >>>>
> > >>>>---------------------------------------------------------------------
> > >>>>To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > >>>>For additional commands, e-mail: users-help@maven.apache.org
> > >>>>
> > >>>>
> > >>>
> > >>>---------------------------------------------------------------------
> > >>
> > >>
> > >>>To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > >>>For additional commands, e-mail: users-help@maven.apache.org
> > >>
> > >>
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > > For additional commands, e-mail: users-help@maven.apache.org
> > >
> > >
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
> --
> jvz.
>
> Jason van Zyl
> jason at maven.org
> http://maven.apache.org
>
> happiness is like a butterfly: the more you chase it, the more it will
> elude you, but if you turn your attention to other things, it will come
> and sit softly on your shoulder ...
>
>  -- Thoreau
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: [M2] Plugin Classloaders

Posted by Jason van Zyl <ja...@maven.org>.
On Fri, 2005-09-23 at 16:49 -0300, Peter Lynch wrote:
> Sorry this may be old news but, but I am wondering if Maven 2 has plugin 
> classloader seperation to avoid this? I'm scared of what the answer 
> might be ;)

In m2 plug-ins are actually executed from their own Plexus child
container which has its own classloader. We have sometimes had problems
with libraries that are needed by Maven itself but for things like
commons-foo different versions used by different plug-ins should, in
theory, be Just Fine(tm). :-)



> -Peter
> 
> Brett Porter wrote:
> > I don't think this is a specific bug as much as it might be a weird
> > combination of dependencies that clash. We'll see. Plugin classloader
> > separation would probably fix it (but break most everything else that
> > assumes all those dependencies are laying around in one classloader :)
> > 
> > - Brett
> > 
> > 
> > On Wed, 22 Sep 2004 14:55:54 +0200, Eric Pugh <ep...@upstate.com> wrote:
> > 
> >>Brett,
> >>
> >>I like seeing a bug that I thought was going to end up on my plate on
> >>someone elses!  If I can help test this, let me know..  I have had some icky
> >>problems in the past with changing around the template used by the CC
> >>plugin, but this specific bug isn't something I ever had..
> >>
> >>Eric
> >>
> >>
> >>
> >>
> >>>-----Original Message-----
> >>>From: Brett Porter [mailto:brett.porter@gmail.com]
> >>>Sent: Wednesday, September 22, 2004 1:59 PM
> >>>To: Maven Users List
> >>>Subject: Re: cruisecontrol:configure
> >>>
> >>>
> >>>MAVEN.
> >>>
> >>>Thanks
> >>>
> >>>
> >>>On Wed, 22 Sep 2004 13:56:45 +0200,
> >>>nicolas.chalumeau@arsoe-trelaze.com
> >>><ni...@arsoe-trelaze.com> wrote:
> >>>
> >>>>In the MPCRUISECONTROL or MAVEN jira module ?
> >>>>
> >>>>Brett Porter <br...@gmail.com>
> >>>>22/09/2004 12:36
> >>>>Veuillez répondre à "Maven Users List"
> >>>>
> >>>>        Pour :  Maven Users List <us...@maven.apache.org>
> >>>>        cc :
> >>>>        Objet : Re: cruisecontrol:configure
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>classpath issue. Please post this to JIRA with maven --info output.
> >>>>
> >>>>- Brett
> >>>>
> >>>>On Wed, 22 Sep 2004 10:12:13 +0200,
> >>>>nicolas.chalumeau@arsoe-trelaze.com
> >>>><ni...@arsoe-trelaze.com> wrote:
> >>>>
> >>>>>I use cc 2.1.6 with the the 1.5 plugin. It seem I have a probleme with
> >>>>
> >>>>the
> >>>>
> >>>>>jsl:template tag. I try by setting the properties
> >>>>
> >>>>maven.cruisecontrol.template=cruisecontrol or use it with the default
> >>>>value but there is no change
> >>>>
> >>>>>allways the same message.
> >>>>>I probally forgot to set some properties or don't set them
> >>>
> >>>with correct
> >>>
> >>>>>value.
> >>>>>
> >>>>>[Propri\351taire@draken ...maven-struts-module-plugin/]$ maven
> >>>>>cruisecontrol:configure
> >>>>> __  __
> >>>>>|  \/  |__ _Apache__ ___
> >>>>>| |\/| / _` \ V / -_) ' \  ~ intelligent projects ~
> >>>>>|_|  |_\__,_|\_/\___|_||_|  v. 1.0
> >>>>>
> >>>>>build:start:
> >>>>>
> >>>>>scm:parse-connection:
> >>>>>    [echo] Using connection:
> >>>>>
> >>>>
> >>>scm:cvs:pserver:nicolas@cvs.codeczar.com:/usr/ngasi/contexts/codec
> >>>zar/cvs:maven-struts-module-plugin
> >>>
> >>>>>Using SCM method: cvs
> >>>>>Using CVSROOT:
> >>>>>:pserver:nicolas@cvs.codeczar.com:/usr/ngasi/contexts/codeczar/cvs
> >>>>>Using module: maven-struts-module-plugin
> >>>>>
> >>>>>BUILD FAILED
> >>>>>File...... C:\Documents and
> >>>>>
> >>>>
> >>>Settings\PropriÚtaire\.maven\cache\maven-cruisecontrol-plugin-1.5\
> >>>plugin.jelly
> >>>
> >>>>>Element... j:include
> >>>>>Line...... 72
> >>>>>Column.... 51
> >>>>>file:C:/Documents and
> >>>>>
> >>>>
> >>>Settings/PropriÚtaire/.maven/cache/maven-cruisecontrol-plugin-1.5/
> >>>plugin-resources/cruisecontrol.jsl:30:52:
> >>>
> >>>>><jsl:template
> >>>>> > Property 'match' has no write method
> >>>>>Total time: 4 seconds
> >>>>>Finished at: Wed Sep 22 20:56:03 GMT+01:00 2004
> >>>>>
> >>>>>So if some one have any idea ...
> >>>>>
> >>>>>I solve it temporary by comment the jsl:template tag in the
> >>>>
> >>>>cruisecontrol.jsl but it is a very bad thing
> >>>>
> >>>>>Nicolas
> >>>>>
> >>>>>---------------------------------------------------------------------
> >>>>>To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >>>>>For additional commands, e-mail: users-help@maven.apache.org
> >>>>>
> >>>>>
> >>>>
> >>>>---------------------------------------------------------------------
> >>>>To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >>>>For additional commands, e-mail: users-help@maven.apache.org
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>---------------------------------------------------------------------
> >>>>To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >>>>For additional commands, e-mail: users-help@maven.apache.org
> >>>>
> >>>>
> >>>
> >>>---------------------------------------------------------------------
> >>
> >>
> >>>To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >>>For additional commands, e-mail: users-help@maven.apache.org
> >>
> >>
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> > 
> > 
> > 
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
-- 
jvz.

Jason van Zyl
jason at maven.org
http://maven.apache.org

happiness is like a butterfly: the more you chase it, the more it will
elude you, but if you turn your attention to other things, it will come
and sit softly on your shoulder ...

 -- Thoreau 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org