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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Thanks,
Jason
----------------------------------------------------------
Jason van Zyl
Founder, Apache Maven
jason at sonatype dot com
----------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]