It's definitely a classloading issue as I was ultimately able to do what I 
needed to do with reflection. But that code is really ugly and I'd like to 
understand the problem. Rolling back to 2.0.8 isn't really an option as I have 
some projects that are dependent upon the deterministic dependency ordering 
added in 2.0.9.
 
Anyway, here's what I tried:
 
Scenario 1:
* Plugin contains custom wagon and components.xml
* Plugin has a dependnecy on wagon-ssh
 
Scenario 2:
* Plugin has a dependency on custom wagon project
* Custom wagon project contains custom wagon and components.xml
* Custom wagon project depends upon wagon-ssh
 
Scenario 3:
* No custom wagon, switched back to ScpWagon.
* WagonManager is injected with @parameter 
expression="${component.org.apache.maven.artifact.manager.WagonManager}"
* Call wagonManager.getWagon(repository); (where repository.url starts with 
scp://)
* BUT resulting wagon can't be cast to ScpWagon and instanceof ScpWagon fails
* Plugin has a dependnecy on wagon-ssh
(because I'm trying to get access to ScpWagon.session and that's protected, I 
figured I'd drop a class in the same package so that the protected variable 
would be visible; hacky but it should have worked)
 
Somewhere in there I tried some other strange things that gave me 
AbstractMethod and NoSuchMethod errors.
 
Justin

________________________________

From: Brett Porter [mailto:[EMAIL PROTECTED]
Sent: Thu 9/4/2008 8:11 PM
To: Maven Users List
Subject: Re: Stuck on custom wagon and plexus



Sorry, it should have been clear to me where you were instantiating it :)
I think this is still a classloading issue, as it is a clash between the
built-in wagon-ssh and the dependency you are trying to use.

If you are using Maven 2.0.9, try again with Maven 2.0.8 (it might also be
this bug: http://jira.codehaus.org/browse/MNG-3581).

Just so I clearly understand the structure:
- the wagon you are using is inside the plugin itself, as well as the
components.xml
- the plugin has a dependency on wagon-ssh

Is that right?

Cheers,
Brett

2008/9/4 Edelson, Justin <[EMAIL PROTECTED]>

> FWIW (probably not much) I also tried merging my two projects into one and
> see the same result.
>
> Justin
>
> ________________________________
>
> From: Edelson, Justin
> Sent: Thu 9/4/2008 8:14 AM
> To: [email protected]
> Subject: Re: Stuck on custom wagon and plexus
>
>
>
> I'm not instantiating the wagon - Plexus should be doing that and injecting
> it into my plugin. My plugin project depends upon my wagon projecy which
> depends upon wagon-ssh (which contains ScpWagon). Scope for the dependencies
> are both compile.
>
> Thanks,
> Justin
>
> ----- Original Message -----
> From: Brett Porter <[EMAIL PROTECTED]>
> To: Maven Users List <[email protected]>
> Sent: Wed Sep 03 23:11:00 2008
> Subject: Re: Stuck on custom wagon and plexus
>
> this could be a classloading issue.
> How are you instantiating the wagon, and how are you declaring it to Maven
> (is it just a dependency of the plugin?)
>
> - Brett
>
> 2008/9/4 Edelson, Justin <[EMAIL PROTECTED]>
>
> > Thanks Brett. I knew it was something simple.
> >
> > That got me one step further, now I'm getting:
> > Caused by:
> org.codehaus.plexus.component.composition.CompositionException:
> > Composition failed for the field knownHostsProvider in object of type
> > com.mtvi.plateng.maven.wagon.JschTunnelWagon
> >        at
> >
> org.codehaus.plexus.component.composition.FieldComponentComposer.assignRequirementToField(FieldComponentComposer.java:144)
> >        at
> >
> org.codehaus.plexus.component.composition.FieldComponentComposer.assembleComponent(FieldComponentComposer.java:73)
> >        at
> >
> org.codehaus.plexus.component.composition.DefaultComponentComposerManager.assembleComponent(DefaultComponentComposerManager.java:68)
> >        at
> >
> org.codehaus.plexus.DefaultPlexusContainer.composeComponent(DefaultPlexusContainer.java:1486)
> >        at
> >
> org.codehaus.plexus.personality.plexus.lifecycle.phase.CompositionPhase.execute(CompositionPhase.java:29)
> >        ... 35 more
> > Caused by: java.lang.IllegalArgumentException
> >        at
> >
> sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
> >        at java.lang.reflect.Field.set(Field.java:656)
> >        at
> >
> org.codehaus.plexus.component.composition.FieldComponentComposer.assignRequirementToField(FieldComponentComposer.java:137)
> >        ... 39 mor
> >
> > knownHostsProvider is a field in AbstractJschWagon, which is extended by
> > ScpWagon, which my class then extends. I basically just copied the
> component
> > configuration from that of ScpWagon
> >
> >
> >
> >
> > ________________________________
> >
> > From: Brett Porter [mailto:[EMAIL PROTECTED]
> > Sent: Wed 9/3/2008 9:57 PM
> > To: Maven Users List
> > Subject: Re: Stuck on custom wagon and plexus
> >
> >
> >
> > Is the resource really in that directory?
> > It should be src/main/resources/META-INF/plexus/components.xml instead :)
> >
> > Cheers,
> > Brett
> >
> > 2008/9/4 Edelson, Justin <[EMAIL PROTECTED]>
> >
> > > I'm writing a Maven plugin that requires a customized version of the
> SCP
> > > Wagon. While I've written a number of plugins in the past, this is the
> > first
> > > time I've tried to create a Plexus component and I seem to be stuck.
> > >
> > > Here's what I've done:
> > > * In one project, I have a class (...JschTunnelWagon), an interface
> > > (...TunnelWagon), and a components.xml file (in
> > src/main/resources/plexus)
> > > with this content:
> > > <component-set>
> > >  <components>
> > >    <component>
> > >      <role>org.apache.maven.wagon.Wagon</role>
> > >      <role-hint>ssh-pf</role-hint>
> > >
> > >
> >
>  <implementation>com.mtvi.plateng.maven.wagon.JschTunnelWagon</implementation>
> > >
> > > [other configuration]
> > >
> > >    </component>
> > >  </components>
> > > </component-set>
> > > * In my plugin project, I depend upon the first project and do this:
> > >    /**
> > >     * The Tunneling Wagon.
> > >     *
> > >     * @parameter
> > > expression="${component.org.apache.maven.wagon.Wagon#ssh-pf}"
> > >     * @required
> > >     * @readonly
> > >     */
> > >    private TunnelWagon wagon;
> > >
> > > When I try to execute my mojo, I get this error:
> > > Component descriptor cannot be found in the component repository:
> > > org.apache.maven.wagon.Wagonssh-pf.
> > >
> > > With -X, I see this:
> > > Caused by:
> > org.codehaus.plexus.component.composition.CompositionException:
> > > Composition failed of field wagon in object of type
> > > com.mtvi.plateng.maven.utils.TunnelCreatorMojo because the requirement
> > > ComponentRequirement{role='org.apache.maven.wagon.Wagon',
> > roleHint='ssh-pf',
> > > fieldName='wagon'} was missing
> > >
> > > I'm sure I'm missing something simple, but if anyone can help, I'd
> > > appreciate it.
> > >
> > > Thanks,
> > > Justin
> > >
> > >
> >
> >
> > --
> > Brett Porter
> > Blog: http://blogs.exist.com/bporter/
> >
> >
> >
>
>
> --
> Brett Porter
> Blog: http://blogs.exist.com/bporter/
>
>
>


--
Brett Porter
Blog: http://blogs.exist.com/bporter/


Reply via email to