You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Tom Huybrechts <to...@gmail.com> on 2007/10/14 22:43:56 UTC

MavenEmbedder says "cannot lookup required component"

I'm trying to integrate Maven into a STAF [1] service using the
embedder (the latest 2.1 snapshot).

During startup, the embedder gives me this exception:

org.apache.maven.embedder.MavenEmbedderException: Cannot lookup
required component.
        at org.apache.maven.embedder.MavenEmbedder.start(MavenEmbedder.java:647)
        at org.apache.maven.embedder.MavenEmbedder.<init>(MavenEmbedder.java:194)
        at com.agfa.staf.MyStafService.createEmbedder(MyStafService.java:149)
        at com.agfa.staf.MyStafService.resolveArtifact(MyStafService.java:156)
        at com.agfa.staf.MyStafService.handleRegister(MyStafService.java:63)
        at com.agfa.staf.MyStafService.acceptRequest(MyStafService.java:44)
        at com.ibm.staf.service.STAFServiceHelper.callService(STAFServiceHelper.java:349)
Caused by: org.codehaus.plexus.component.repository.exception.ComponentLookupException:
Component descriptor cannot be found in the component reposito
ry: org.apache.maven.Maven [default] (lookup realm:
ClassRealm[plexus.core, parent: null]).
        at org.codehaus.plexus.DefaultComponentLookupManager.lookup(DefaultComponentLookupManager.java:139)
        at org.codehaus.plexus.DefaultComponentLookupManager.lookup(DefaultComponentLookupManager.java:69)
        at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:247)
        at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:241)
        at org.apache.maven.embedder.MavenEmbedder.start(MavenEmbedder.java:595)
        ... 6 more

The code that starts the embedder looks like this:

		Configuration configuration = new DefaultConfiguration();
		ClassLoader loader = MavenEmbedder.class.getClassLoader();
		configuration.setClassLoader(loader);
		configuration.setMavenEmbedderLogger(new MavenEmbedderConsoleLogger());

		ConfigurationValidationResult validation = MavenEmbedder
				.validateConfiguration(configuration);
		if (!validation.isValid()) {
			throw new RuntimeException("Not valid");
		}
		MavenEmbedder embedder = new MavenEmbedder(configuration);


This code works when I run it in a normal environment (both my code
and the embedder on the CLASSPATH) but fails with the above exception
when running it as a STAF service. The difference between these
environments is that the STAF service has a special classloader. A
STAF service jar looks like this:

/STAF-INF/classes: contains classes
/STAF-INF/jars: contains extra libs ( maven-embedder.jar )

This is the classloader used:
http://staf.cvs.sourceforge.net/staf/src/staf/lang/java/service/STAFServiceJarClassLoader.java?revision=1.14&view=markup


Does anybody know what the problem is here ? Does the embedder or
Plexus expect its code in an ordinary jar ?

Tom

[1] Software Testing Automation Framework at
http://staf.sourceforge.net/index.php

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


Re: MavenEmbedder says "cannot lookup required component"

Posted by Jason van Zyl <ja...@maven.org>.
You have a findResource( resource)  in that implementation but not an  
implementation of findResources( resource ) which is the method that  
Plexus uses to find the components.xml files. You extends ClassLoader  
which I believe returns an empty Enumeration:

http://www.docjar.org/html/api/java/lang/ClassLoader.java.html

Just use your findResource( resource ) implementation to cycle  
through and return them all.

On 14 Oct 07, at 1:43 PM 14 Oct 07, Tom Huybrechts wrote:

> I'm trying to integrate Maven into a STAF [1] service using the
> embedder (the latest 2.1 snapshot).
>
> During startup, the embedder gives me this exception:
>
> org.apache.maven.embedder.MavenEmbedderException: Cannot lookup
> required component.
>         at org.apache.maven.embedder.MavenEmbedder.start 
> (MavenEmbedder.java:647)
>         at org.apache.maven.embedder.MavenEmbedder.<init> 
> (MavenEmbedder.java:194)
>         at com.agfa.staf.MyStafService.createEmbedder 
> (MyStafService.java:149)
>         at com.agfa.staf.MyStafService.resolveArtifact 
> (MyStafService.java:156)
>         at com.agfa.staf.MyStafService.handleRegister 
> (MyStafService.java:63)
>         at com.agfa.staf.MyStafService.acceptRequest 
> (MyStafService.java:44)
>         at com.ibm.staf.service.STAFServiceHelper.callService 
> (STAFServiceHelper.java:349)
> Caused by:  
> org.codehaus.plexus.component.repository.exception.ComponentLookupExce 
> ption:
> Component descriptor cannot be found in the component reposito
> ry: org.apache.maven.Maven [default] (lookup realm:
> ClassRealm[plexus.core, parent: null]).
>         at org.codehaus.plexus.DefaultComponentLookupManager.lookup 
> (DefaultComponentLookupManager.java:139)
>         at org.codehaus.plexus.DefaultComponentLookupManager.lookup 
> (DefaultComponentLookupManager.java:69)
>         at org.codehaus.plexus.DefaultPlexusContainer.lookup 
> (DefaultPlexusContainer.java:247)
>         at org.codehaus.plexus.DefaultPlexusContainer.lookup 
> (DefaultPlexusContainer.java:241)
>         at org.apache.maven.embedder.MavenEmbedder.start 
> (MavenEmbedder.java:595)
>         ... 6 more
>
> The code that starts the embedder looks like this:
>
> 		Configuration configuration = new DefaultConfiguration();
> 		ClassLoader loader = MavenEmbedder.class.getClassLoader();
> 		configuration.setClassLoader(loader);
> 		configuration.setMavenEmbedderLogger(new  
> MavenEmbedderConsoleLogger());
>
> 		ConfigurationValidationResult validation = MavenEmbedder
> 				.validateConfiguration(configuration);
> 		if (!validation.isValid()) {
> 			throw new RuntimeException("Not valid");
> 		}
> 		MavenEmbedder embedder = new MavenEmbedder(configuration);
>
>
> This code works when I run it in a normal environment (both my code
> and the embedder on the CLASSPATH) but fails with the above exception
> when running it as a STAF service. The difference between these
> environments is that the STAF service has a special classloader. A
> STAF service jar looks like this:
>
> /STAF-INF/classes: contains classes
> /STAF-INF/jars: contains extra libs ( maven-embedder.jar )
>
> This is the classloader used:
> http://staf.cvs.sourceforge.net/staf/src/staf/lang/java/service/ 
> STAFServiceJarClassLoader.java?revision=1.14&view=markup
>
>
> Does anybody know what the problem is here ? Does the embedder or
> Plexus expect its code in an ordinary jar ?
>
> Tom
>
> [1] Software Testing Automation Framework at
> http://staf.sourceforge.net/index.php
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>

Thanks,

Jason

----------------------------------------------------------
Jason van Zyl
Founder,  Apache Maven
jason at sonatype dot com
----------------------------------------------------------




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