[HAP-954] Maven builds fail with ComponentLookupException when having a maven extensions.xml file in project Created: 13/Jul/17  Updated: 31/Dec/19  Resolved: 31/Dec/19

Status: Resolved
Project: Jenkins Artifactory Plug-in
Component/s: Maven3
Affects Version/s: 3.4.0
Fix Version/s: 3.5.0

Type: Improvement Priority: Normal
Reporter: Jon Gunnip Assignee: Yahav Itzhak
Resolution: Fixed Votes: 3
Labels: None

Issue Links:
Relationship
relates to BI-508 Maven builds fail with ComponentLooku... Resolved
relates to HAP-1250 Hangs when Using with pipeline-maven-... Resolved

 Description   

Have the following in .mvn/extensions.xml in my project:

<?xml version="1.0" encoding="UTF-8"?>
<extensions>
	<extension>
		<groupId>io.takari.maven</groupId>
		<artifactId>takari-smart-builder</artifactId>
		<version>0.5.0</version>
	</extension>
	<extension>
		<groupId>io.takari.aether</groupId>
		<artifactId>takari-concurrent-localrepo</artifactId>
		 <version>0.0.7</version>
	</extension>
	<extension>
		<groupId>io.takari.aether</groupId>
		<artifactId>aether-connector-okhttp</artifactId>
		<version>1.0.1-alpha</version>
	</extension>	
</extensions>

This is needed for thread-safe multithreaded multi-module builds. These extensions would normally only be invoked passing --builder smart when invoking mvn.

With artifactory plugin, I get the following exception just by having that file present but not invoking --builder smart

[eature_jenkins-staged-build-ODERDWEQO2CZLFQ55CNVTN5HSO6IA557XQUPPEP6WCBJFNOHFLXA] $ /opt/java_1.8_64/bin/java -classpath /opt/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.3.9/boot/plexus-classworlds-2.5.2.jar -Dmaven.home=/opt/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.3.9 -DbuildInfoConfig.propertiesFile=/tmp/buildInfo2408750196954894694.properties -Dm3plugin.lib=/opt/jenkins/cache/artifactory-plugin/2.12.0 -Dclassworlds.conf=/tmp/classworlds2689192953410105179conf -Dmaven.multiModuleProjectDirectory=/opt/jenkins/workspace/eature_jenkins-staged-build-ODERDWEQO2CZLFQ55CNVTN5HSO6IA557XQUPPEP6WCBJFNOHFLXA -Xmx1024m org.codehaus.plexus.classworlds.launcher.Launcher -f pom.xml clean install -DskipTests -Pci -U -Dmaven.repo.local=.repository
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Scanning for projects...
[main] ERROR org.jfrog.build.extractor.maven.resolver.ArtifactoryEclipseRepositoryListener - Failed while enforcing Artifactory artifact resolver
org.codehaus.plexus.component.repository.exception.ComponentLookupException: java.util.NoSuchElementException
      role: org.jfrog.build.extractor.maven.resolver.ArtifactoryEclipseArtifactResolver
  roleHint: 
	at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:267)
	at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:243)
	at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:237)
	at org.jfrog.build.extractor.maven.resolver.ArtifactoryEclipseRepositoryListener.enforceArtifactoryResolver(ArtifactoryEclipseRepositoryListener.java:71)
	at org.jfrog.build.extractor.maven.resolver.ArtifactoryEclipseRepositoryListener.contextualize(ArtifactoryEclipseRepositoryListener.java:258)
	at org.eclipse.sisu.plexus.PlexusLifecycleManager.contextualize(PlexusLifecycleManager.java:282)
	at org.eclipse.sisu.plexus.PlexusLifecycleManager.activate(PlexusLifecycleManager.java:203)
	at org.eclipse.sisu.bean.BeanScheduler$Pending.activate(BeanScheduler.java:156)
	at org.eclipse.sisu.bean.BeanScheduler$Activator.onProvision(BeanScheduler.java:185)
	at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:126)
	at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:68)
	at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:63)
	at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:45)
	at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
	at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103)
	at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
	at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:145)
	at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
	at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1016)
	at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
	at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1012)
	at org.eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.java:81)
	at org.eclipse.sisu.wire.EntrySetAdapter$ValueIterator.next(EntrySetAdapter.java:102)
	at org.eclipse.aether.internal.impl.DefaultRepositoryEventDispatcher.dispatch(DefaultRepositoryEventDispatcher.java:91)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.artifactResolving(DefaultArtifactResolver.java:662)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:276)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:223)
	at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:294)
	at org.apache.maven.project.ProjectModelResolver.resolveModel(ProjectModelResolver.java:193)
	at org.apache.maven.model.building.DefaultModelBuilder.importDependencyManagement(DefaultModelBuilder.java:1192)
	at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:455)
	at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:421)
	at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:620)
	at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:411)
	at org.apache.maven.graph.DefaultGraphBuilder.collectProjects(DefaultGraphBuilder.java:419)
	at org.apache.maven.graph.DefaultGraphBuilder.getProjectsForMavenReactor(DefaultGraphBuilder.java:410)
	at org.apache.maven.graph.DefaultGraphBuilder.build(DefaultGraphBuilder.java:83)
	at org.apache.maven.DefaultMaven.buildGraph(DefaultMaven.java:491)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:219)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
	at java.lang.reflect.Method.invoke(Method.java:507)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.util.NoSuchElementException
	at java.util.Collections$EmptyIterator.next(Collections.java:4200)
	at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:263)
	... 52 more

Removing the .mvn/extensions.xml file allows the build to proceed, but I can't then do multi-threaded multi-module builds.



 Comments   
Comment by Jesper [ 18/Jul/19 ]

I can confirm that this is still an issue.  

I'm trying to build an Atlassian plugin, and now with the updated Atlassian SDK 8.0.0 they bundle maven 3.5.4.  

Maven added the feature of core extensions in 3.3.1 (.mvn/extensions.xml), and currently I'm using it to load the com.github.gzm55.maven:project-settings-extension:0.1.1 extension, which can inject a settings file stored in .mvn/settings.xml as if you ran maven with the -s .mvn/settings.xml argument.

This is pretty nifty when you want to easily setup your local Artifactory instance as a mirror of jcenter, etc, and have that work seamlessly when your CI pipeline pulls and builds your code.

I tested it a little, and it seems that the mentioned exception in ArtifactoryEclipseRepositoryListener is thrown as soon as you have an actual <extension>...</extension> defined, but just having the following in .mvn/extensions.xml works>

<extensions xmlns="..." xmlns:xsi="..." xsi:schemaLocation="...">

</extensions>
 

I tried looking at the build-info source, however the plexusContainer.lookup stuff is beyond my java skills, and I didn't find an easy way to debug it.

Comment by Jesper [ 18/Jul/19 ]

Eyal Ben Moshe, This bug is from Jul 2017. Any comments on plans to look at it?

Comment by Jesper [ 18/Jul/19 ]

After some more digging, then it seems that a similar issue was reported against the jgitver-maven-plugin, where they found the issue to not be with them or the other plugins, but related to artifactory-plugin / build-info when used in combination with extensions (See jgitver-maven-plugin#55).

I forgot to mention previously that I'm testing this using jenkins-artifactory-plugin 3.3.2 and Jenkins 2.164.2

 

Comment by Michael Lasevich [ 25/Oct/19 ]

Seeing same thing when combining "withMaven" with Artifactory plugin. Any clue if this is ever going to be looked at?

Comment by Yahav Itzhak [ 21/Nov/19 ]

Jon Gunnip, Michael Lasevich Jesper

Sorry that it took too long. We fixed this issue!

Here is the commit that resolves this issue: https://github.com/jfrog/build-info/commit/3fdb07b85fe40eb90712ecbe545f326794226629

Here is a snapshot with the fix: https://oss.jfrog.org/oss-snapshot-local/org/jenkins-ci/plugins/artifactory/3.4.x-SNAPSHOT/artifactory-3.4.x-20191120.113432-21.hpi

We'll appreciate feedback for that!

Comment by Jesper [ 22/Nov/19 ]

Can't wait to test it.

Comment by Michael Lasevich [ 22/Nov/19 ]

Just tested it, and on the first try it seems to work much better in my use case (HAP-1250

Comment by Michael Lasevich [ 22/Nov/19 ]

What is the ETA for a release with this in it?

Comment by Yahav Itzhak [ 30/Dec/19 ]

Jon Gunnip, Michael Lasevich Jesper

Jenkins Artifactory plugin 3.5.0 is released. Feel free to upgrade.

We'll appreciate your feedback for that!

Generated at Wed Feb 19 05:19:44 UTC 2020 using JIRA 7.6.16#76018-sha1:9ed376192612a49536ac834c64177a0fed6290f5.