[prev in list] [next in list] [prev in thread] [next in thread] 

List:       maven-user
Subject:    RE: MavenEmbedder problem with 3.1.x
From:       Bernd Adamowicz <Bernd.Adamowicz () esailors ! de>
Date:       2013-11-20 16:41:34
Message-ID: 2C63E27EA7DC8B4381614A8131CE1FEA068A28B69B () Elbe ! mare ! esailors ! net
[Download RAW message or body]

Amazing! This works!

I tried so many permutations of dependency version, but obviously never got the right \
one. Thanks a lot Stuart!

-- 
Bernd Adamowicz


-----Original Message-----
From: Stuart McCulloch [mailto:mcculls@gmail.com] 
Sent: Mittwoch, 20. November 2013 16:04
To: Maven Users List
Subject: Re: MavenEmbedder problem with 3.1.x

Update the lib-jenkins-maven-embedder dependency to version 3.11, since this is the \
version that works with the latest aether/sisu dependencies.

On 20 Nov 2013, at 09:41, Bernd Adamowicz wrote:

> No answer so far. Should I file a bug? Any opinion?
> 
> Bernd Adamowicz
> 
> 
> -----Original Message-----
> From: Bernd Adamowicz [mailto:Bernd.Adamowicz@esailors.de]
> Sent: Montag, 18. November 2013 16:12
> To: users@maven.apache.org
> Subject: MavenEmbedder problem with 3.1.x
> 
> Hi all,
> 
> When switching from Maven 3.0.x to 3.1.x some of our projects where not able to \
> execute anymore due to a problem with MavenEmbedder. Both projects are command line \
> based, no Maven plugin around it. 
> I think the most important part of the stack trace is this:
> 
> 37) No implementation for \
> java.util.Set<org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory> was \
> bound. while locating \
> java.util.Set<org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory> for \
> parameter 0 at  org.eclipse.aether.internal.impl.DefaultLocalRepositoryProvider.<init>
>  (Unknown
> ...
> 37 errors
> role: org.apache.maven.execution.MavenExecutionRequestPopulator
> roleHint:
> at com.google.inject.internal.InjectorImpl$3.get(InjectorImpl.java:974)
> at org.eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.java:82)
> at org.eclipse.sisu.plexus.LazyPlexusBean.getValue(LazyPlexusBean.java:51)
> at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:260)
>  at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:252)
>  at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:246)
>  at hudson.maven.MavenEmbedder.lookup(MavenEmbedder.java:567)
> at hudson.maven.MavenEmbedder.buildMavenExecutionRequest(MavenEmbedder.java:157)
> at hudson.maven.MavenEmbedder.<init>(MavenEmbedder.java:120)
> at hudson.maven.MavenEmbedder.<init>(MavenEmbedder.java:109)
> at hudson.maven.MavenEmbedder.<init>(MavenEmbedder.java:136)
> at test.embedder.AppTest.testLookup(AppTest.java:57)
> 
> I know this problem came when I changed my aether-dependencies from \
> 'org.sonatype.aether' to 'org.eclipse.aether' in order to work with Maven 3.1.x. 
> Fortunately this can be reproduced with a simple project which can be 
> found here: 
> https://dl.dropboxusercontent.com/u/86229859/embedder-test.tgz
> 
> Usage of the MavenEmbedder looks like this:
> 
> package test.embedder;
> import hudson.maven.MavenEmbedder;
> import hudson.maven.MavenEmbedderException;
> import hudson.maven.MavenRequest;
> import java.io.File;
> import org.apache.maven.model.building.ModelBuildingRequest;
> import org.apache.maven.project.MavenProject;
> 
> public class App {
> private static final ClassLoader                mavenClassLoader = \
> App.class.getClassLoader(); private static final ThreadLocal<MavenEmbedder> \
> embedder         = new ThreadLocal<MavenEmbedder>() { 
> @Override
> protected MavenEmbedder initialValue() {
> try {
> MavenRequest req = new MavenRequest();
> req.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1);
> return new MavenEmbedder(mavenClassLoader, req);
> } catch (MavenEmbedderException e) {
> throw new RuntimeException(
> "Error creating MavenEmbedder", e);
> }
> }
> };
> 
> public static MavenProject getMavenProject(File pomFile) {
> try {
> return embedder.get().readProject(pomFile);
> } catch (Exception e) {
> throw new RuntimeException("Error parsing POM at " + pomFile, e);
> }
> }
> }
> 
> This unit test will then trigger the error:
> 
> package test.embedder;
> import static org.testng.AssertJUnit.assertEquals;
> import static org.testng.AssertJUnit.assertNotNull;
> import java.io.File;
> import org.apache.commons.io.FileUtils; import 
> org.apache.maven.project.MavenProject;
> import org.testng.annotations.BeforeClass;
> import org.testng.annotations.Test;
> 
> public class AppTest {
> private static File mvnUtilFolder = null;
> @BeforeClass
> public static void setUpBeforeClass() throws Exception {
> mvnUtilFolder = FileUtils.toFile(AppTest.class.getClassLoader().getResource("mvnUtil"));
>  }
> 
> @Test
> public void testGetMavenProject() {
> File mvnPom = new File(mvnUtilFolder.getAbsolutePath() + "/pom.xml");
> MavenProject mvnProject = App.getMavenProject(mvnPom);
> assertNotNull(mvnProject);
> assertEquals("3.5.2", mvnProject.getVersion());
> }
> }
> 
> For me all this looks like a 'simple' classloader issue when Guice tries to load \
> the classes (e.g.:  org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory) \
> but can't find them. 
> I've googled presumably all the places dealing with problems when switching from \
> 3.0.x to 3.1.x and tried a lot of things without success. In particular: 
> * fixed all versions of plugins as described here: 
> https://cwiki.apache.org/confluence/display/MAVEN/AetherClassNotFound
> * changed dependencies to Ather as described here: 
> http://eclipse.org/aether
> * basically I implemented things the way they are done in the 
> lib-jenkins implementation itself here: 
> https://github.com/jenkinsci/lib-jenkins-maven-embedder/blob/master/sr
> c/test/java/hudson/maven/TestMavenEmbedderSimpleProject.java
> * tried to deal with different versions of validation level \
>                 'req.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1)'
>                 
> * tried myriads of different POM configurations (dependencies, 
> versions)
> 
> But actually this error persists (also when building with 3.0.x). So maybe anyone \
> can point me to the right direction? I've dealt with this problem too long now and \
> maybe I got blind for new approaches. Thanks in advance! 
> Bernd
> 
> 
> ---------------------------------------------------------------------
> 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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic