Good day to you, Arnaud,
Just a hunch
The Symptom:
Somewhere along the stacktrace, a component failed to get composed because
of a NoClassDefFoundError exception.
Solution:
I think the expected transitive dependency was broken. You may want to
declare the binary containing the "NoClassDefFoundError class" as a direct
dependency of your project. ..also, you may want to take a look at your
dependency tree ( i.e by using "mvn project-info-reports:dependencies -X" )
to have a better idea of what's happening.
Explanation of what may be happening:
I experienced something like this before. And this is how it went with
mine...
I had a project grp.id:proj-a:1. And it's dependency tree looked something
like this
grp.id:proj-a:1
|-- grp.id:proj-b:1
| `-- grp.id:proj-c:1
|`-- grp.id:proj-d:2 <~ did not get included
`-- grp.id:proj-e:1
`-- grp.id:proj-d:1 <~ was chosen over version 2
the difference between grp.id:proj-d:1 and grp.id:proj-d:2 is that
grp.id:proj-d:2 has a class MyClass.
Thus, when my project grp.id:proj-a:1 referenced the class MyClass, it was
unable to load it because the version of grp.id:proj-d that got resolved was
version 1 instead of version 2 ( see [1] for more details ).
So to prevent this, I had to declared grp.id:proj-d:2 as a direct dependency
so that i my dependency tree would look something like
grp.id:proj-a:1
|-- grp.id:proj-b:1
| `-- grp.id:proj-c:1
|`-- grp.id:proj-d:2
|-- grp.id:proj-e:1
|`-- grp.id:proj-d:1 <~ did not get included
`-- grp.id:proj-d:2 <~ included
I am not sure though why your dependency tree is different between your
maven commandline and your embedded maven.
Cheers,
Franz
[1] http://docs.codehaus.org/display/MAVENUSER/Dependency+Mechanism
Arnaud Bailly-3 wrote:
>
> Hello,
> I am trying to add some integration tests for a plugin I wrote, using
> MavenEmbedder. When running the test, I got the following impressive
> exception trace:
>
> ---
> Test set: oqube.patchwork.it.PatchworkMavenTest
> ---
> Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.662 sec
> <<< FAILURE!
> test01(oqube.patchwork.it.PatchworkMavenTest) Time elapsed: 0.623 sec
> <<< ERROR!
> org.apache.maven.embedder.MavenEmbedderException: Cannot lookup required
> component.
> at org.apache.maven.embedder.MavenEmbedder.start(MavenEmbedder.java:644)
> at
> oqube.patchwork.it.PatchworkMavenTest.setUp(PatchworkMavenTest.java:48)
> at junit.framework.TestCase.runBare(TestCase.java:125)
> at junit.framework.TestResult$1.protect(TestResult.java:106)
> at junit.framework.TestResult.runProtected(TestResult.java:124)
> at junit.framework.TestResult.run(TestResult.java:109)
> at junit.framework.TestCase.run(TestCase.java:118)
> at junit.framework.TestSuite.runTest(TestSuite.java:208)
> at junit.framework.TestSuite.run(TestSuite.java:203)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at
> org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:210)
> at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:135)
> at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:122)
> at org.apache.maven.surefire.Surefire.run(Surefire.java:129)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at
> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:225)
> at
> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:747)
> Caused by:
> org.codehaus.plexus.component.repository.exception.ComponentLookupException:
> Unable to lookup component 'org.apache.maven.project.MavenProjectBuilder',
> it could not be started
> at
> org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:339)
> at org.codehaus.plexus.embed.Embedder.lookup(Embedder.java:78)
> at org.apache.maven.embedder.MavenEmbedder.start(MavenEmbedder.java:610)
> ... 22 more
> Caused by:
> org.codehaus.plexus.component.repository.exception.ComponentLifecycleException:
> Error starting component
> at
> org.codehaus.plexus.component.manager.AbstractComponentManager.startComponentLifecycle(AbstractCom