Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-7758

o.e.aether.resolution.ArtifactResolutionException incorrectly examined when multiple repositories are involved

    XMLWordPrintableJSON

Details

    Description

      Consider you have three repos defined in your build (could be POM or settings), evaluated in following order:

      1. repo A: serves custom artifacts with group id com.example, due to repo partitioning in Nexus rejects requests to all other group ids with 403
      1. repo B: serves third party artifacts without any restriction from a Nexus repo
      1. repo C: serves Central mirror, last one quried, no restrictions

      Note that order is important! Now add a non-existing dependency to your POM and receive the following behavior:
      ArtifactResolutionException will contain an ArtifactResult with three exceptions:

      • TransferException with nested AuthorizationException,
      • ArtifactNotFoundException,
      • ArtifactNotFoundException.

      ArtifactResolutionException#getCause() will be populated with the TransferException so will org.eclipse.aether.resolution.ArtifactResult.isMissing() take the first exception only into account. E.g., DefaultArtifactDescriptorReader will do if (e.getCause() instanceof ArtifactNotFoundException) which is deceiving.

      Here is a sample for a non-existing artifact:

      [INFO] --- maven-site-plugin:4.0.0-M7-SNAPSHOT:site (default-site) @ mskins-222 ---
      [INFO] Configuring report plugin org.apache.maven.plugins:maven-project-info-reports-plugin:3.4.2
      [WARNING] index report is declared twice in default reportSet
      [INFO] 15 reports configured for maven-project-info-reports-plugin:3.4.2: index, summary, dependency-info, modules, team, scm, issue-management, mailing-lists, dependency-management, dependencies, dependency-convergence, ci-management, plugin-management, plugins, distribution-management
      [INFO] Rendering site for default locale
      Downloading from lda-public: https://deblndw011x.ad001.siemens.net/nexus/content/groups/lda-public/org/apache/apache/29/apache-29-site.xml
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD FAILURE
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time:  3.214 s
      [INFO] Finished at: 2023-04-02T12:51:02+02:00
      [INFO] ------------------------------------------------------------------------
      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:4.0.0-M7-SNAPSHOT:site (default-site) on project mskins-222: SiteToolException: The site descriptor cannot be resolved from the repository: Unable to locate site descriptor: Could not transfer artifact org.apache:apache:xml:site:29 from/to lda-public (https://deblndw011x.ad001.siemens.net/nexus/content/groups/lda-public/): authorization failed for https://deblndw011x.ad001.siemens.net/nexus/content/groups/lda-public/org/apache/apache/29/apache-29-site.xml, status: 403 Forbidden -> [Help 1]
      [ERROR]
      [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
      [ERROR] Re-run Maven using the -X switch to enable full debug logging.
      [ERROR]
      [ERROR] For more information about the errors and possible solutions, please read the following articles:
      [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
      

      for a dependency:

      [INFO] org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
      [ERROR] org.apache.maven.cli.MavenCli - Failed to execute goal org.apache.maven.plugins:maven-site-plugin:4.0.0-M7-SNAPSHOT:site (default-site) on project mskins-222: Failed to get report for org.apache.maven.plugins:maven-project-plugin: Plugin org.apache.maven.plugins:maven-project-plugin:3.4.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-project-plugin:jar:3.4.2: Could not transfer artifact org.apache.maven.plugins:maven-project-plugin:pom:3.4.2 from/to lda-public (https://deblndw011x.ad001.siemens.net/nexus/content/groups/lda-public/): authorization failed for https://deblndw011x.ad001.siemens.net/nexus/content/groups/lda-public/org/apache/maven/plugins/maven-project-plugin/3.4.2/maven-project-plugin-3.4.2.pom, status: 403 Forbidden -> [Help 1]
      org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-site-plugin:4.0.0-M7-SNAPSHOT:site (default-site) on project mskins-222: Failed to get report for org.apache.maven.plugins:maven-project-plugin
          at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:375)
          at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
          at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
          at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
          at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
          at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
          at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:298)
          at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
        
      Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to get report for org.apache.maven.plugins:maven-project-plugin
          at org.apache.maven.reporting.exec.DefaultMavenReportExecutor.buildMavenReports (DefaultMavenReportExecutor.java:167)
          at org.apache.maven.plugins.site.render.AbstractSiteRenderingMojo.getReports (AbstractSiteRenderingMojo.java:198)
          at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
      Caused by: org.apache.maven.plugin.PluginResolutionException: Plugin org.apache.maven.plugins:maven-project-plugin:3.4.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-project-plugin:jar:3.4.2
          at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve (DefaultPluginDependenciesResolver.java:133)
          at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getPluginDescriptor (DefaultMavenPluginManager.java:182)
          at org.apache.maven.reporting.exec.DefaultMavenPluginManagerHelper.getPluginDescriptor (DefaultMavenPluginManagerHelper.java:67)
          at org.apache.maven.reporting.exec.DefaultMavenReportExecutor.buildReportPlugin (DefaultMavenReportExecutor.java:185)
          at org.apache.maven.reporting.exec.DefaultMavenReportExecutor.buildMavenReports (DefaultMavenReportExecutor.java:164)
          at org.apache.maven.plugins.site.render.AbstractSiteRenderingMojo.getReports (AbstractSiteRenderingMojo.java:198)
          at org.apache.maven.plugins.site.render.SiteMojo.execute (SiteMojo.java:108)
          at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
          at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
      Caused by: org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.maven.plugins:maven-project-plugin:jar:3.4.2
          at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom (DefaultArtifactDescriptorReader.java:255)
          at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor (DefaultArtifactDescriptorReader.java:171)
          at org.eclipse.aether.internal.impl.DefaultRepositorySystem.readArtifactDescriptor (DefaultRepositorySystem.java:255)
          at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve (DefaultPluginDependenciesResolver.java:107)
          at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getPluginDescriptor (DefaultMavenPluginManager.java:182)
          at org.apache.maven.reporting.exec.DefaultMavenPluginManagerHelper.getPluginDescriptor (DefaultMavenPluginManagerHelper.java:67)
          at org.apache.maven.reporting.exec.DefaultMavenReportExecutor.buildReportPlugin (DefaultMavenReportExecutor.java:185)
          at org.apache.maven.reporting.exec.DefaultMavenReportExecutor.buildMavenReports (DefaultMavenReportExecutor.java:164)
          at org.apache.maven.plugins.site.render.AbstractSiteRenderingMojo.getReports (AbstractSiteRenderingMojo.java:198)
          at org.apache.maven.plugins.site.render.SiteMojo.execute (SiteMojo.java:108)
          at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
      Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact org.apache.maven.plugins:maven-project-plugin:pom:3.4.2 from/to lda-public (https://deblndw011x.ad001.siemens.net/nexus/content/groups/lda-public/): authorization failed for https://deblndw011x.ad001.siemens.net/nexus/content/groups/lda-public/org/apache/maven/plugins/maven-project-plugin/3.4.2/maven-project-plugin-3.4.2.pom, status: 403 Forbidden
          at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve (DefaultArtifactResolver.java:425)
          at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts (DefaultArtifactResolver.java:229)
          at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact (DefaultArtifactResolver.java:207)
          at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom (DefaultArtifactDescriptorReader.java:240)
          at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor (DefaultArtifactDescriptorReader.java:171)
          at org.eclipse.aether.internal.impl.DefaultRepositorySystem.readArtifactDescriptor (DefaultRepositorySystem.java:255)
          at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve (DefaultPluginDependenciesResolver.java:107)
          at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getPluginDescriptor (DefaultMavenPluginManager.java:182)
          at org.apache.maven.reporting.exec.DefaultMavenPluginManagerHelper.getPluginDescriptor (DefaultMavenPluginManagerHelper.java:67)
          at org.apache.maven.reporting.exec.DefaultMavenReportExecutor.buildReportPlugin (DefaultMavenReportExecutor.java:185)
          at org.apache.maven.reporting.exec.DefaultMavenReportExecutor.buildMavenReports (DefaultMavenReportExecutor.java:164)
          at org.apache.maven.plugins.site.render.AbstractSiteRenderingMojo.getReports (AbstractSiteRenderingMojo.java:198)
          at org.apache.maven.plugins.site.render.SiteMojo.execute (SiteMojo.java:108)
          at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
          at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
      Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact org.apache.maven.plugins:maven-project-plugin:pom:3.4.2 from/to lda-public (https://deblndw011x.ad001.siemens.net/nexus/content/groups/lda-public/): authorization failed for https://deblndw011x.ad001.siemens.net/nexus/content/groups/lda-public/org/apache/maven/plugins/maven-project-plugin/3.4.2/maven-project-plugin-3.4.2.pom, status: 403 Forbidden
          at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed (ArtifactTransportListener.java:52)
          at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run (BasicRepositoryConnector.java:369)
          at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run (RunnableErrorForwarder.java:75)
          at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute (BasicRepositoryConnector.java:628)
          at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get (BasicRepositoryConnector.java:262)
          at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads (DefaultArtifactResolver.java:514)
          at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve (DefaultArtifactResolver.java:402)
          at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts (DefaultArtifactResolver.java:229)
          at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact (DefaultArtifactResolver.java:207)
          at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom (DefaultArtifactDescriptorReader.java:240)
          at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor (DefaultArtifactDescriptorReader.java:171)
          at org.eclipse.aether.internal.impl.DefaultRepositorySystem.readArtifactDescriptor (DefaultRepositorySystem.java:255)
          at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve (DefaultPluginDependenciesResolver.java:107)
          at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getPluginDescriptor (DefaultMavenPluginManager.java:182)
          at org.apache.maven.reporting.exec.DefaultMavenPluginManagerHelper.getPluginDescriptor (DefaultMavenPluginManagerHelper.java:67)
          at org.apache.maven.reporting.exec.DefaultMavenReportExecutor.buildReportPlugin (DefaultMavenReportExecutor.java:185)
          at org.apache.maven.reporting.exec.DefaultMavenReportExecutor.buildMavenReports (DefaultMavenReportExecutor.java:164)
          at org.apache.maven.plugins.site.render.AbstractSiteRenderingMojo.getReports (AbstractSiteRenderingMojo.java:198)
          at org.apache.maven.plugins.site.render.SiteMojo.execute (SiteMojo.java:108)
          at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
          at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
      Caused by: org.apache.maven.wagon.authorization.AuthorizationException: authorization failed for https://deblndw011x.ad001.siemens.net/nexus/content/groups/lda-public/org/apache/maven/plugins/maven-project-plugin/3.4.2/maven-project-plugin-3.4.2.pom, status: 403 Forbidden
          at org.apache.maven.wagon.providers.http.wagon.shared.AbstractHttpClientWagon.fillInputData (AbstractHttpClientWagon.java:1184)
          at org.apache.maven.wagon.providers.http.wagon.shared.AbstractHttpClientWagon.fillInputData (AbstractHttpClientWagon.java:1140)
          at org.apache.maven.wagon.StreamWagon.getInputStream (StreamWagon.java:126)
          at org.apache.maven.wagon.StreamWagon.getIfNewer (StreamWagon.java:88)
          at org.apache.maven.wagon.StreamWagon.get (StreamWagon.java:61)
          at org.eclipse.aether.transport.wagon.WagonTransporter$GetTaskRunner.run (WagonTransporter.java:546)
          at org.eclipse.aether.transport.wagon.WagonTransporter.execute (WagonTransporter.java:430)
          at org.eclipse.aether.transport.wagon.WagonTransporter.get (WagonTransporter.java:407)
          at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
      [ERROR] org.apache.maven.cli.MavenCli -
      [ERROR] org.apache.maven.cli.MavenCli -
      [ERROR] org.apache.maven.cli.MavenCli - For more information about the errors and possible solutions, please read the following articles:
      [ERROR] org.apache.maven.cli.MavenCli - [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
      

      The outcome of this handling is totally dependent on the order of repositories. If the repo A would be at the end the exception stracktrace would be completely different. It is perfectly fine that if one repo is not responding the other one responds properly, regardless if the artifact is found or not. The end result is important.

      Affected components:

      • org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(Artifact, List<ArtifactRepository>, RepositorySystemSession)
      • org.apache.maven.project.artifact.MavenMetadataSource.isMissingPom(Exception)
      • org.apache.maven.project.artifact.MavenMetadataSource.isNonTransferrablePom(Exception)
      • org.apache.maven.project.DefaultProjectBuilder.build(Artifact, boolean, ProjectBuildingRequest)
      • org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(RepositorySystemSession, ArtifactDescriptorRequest, ArtifactDescriptorResult)
      • org.apache.maven.repository.internal.DefaultModelResolver.resolveModel(String, String, String)
      • org.apache.maven.project.ProjectModelResolver.resolveModel(String, String, String)
      • org.apache.maven.project.collector.MultiModuleCollectionStrategy.isModuleOutsideRequestScopeDependingOnPluginModule(MavenExecutionRequest, ProjectBuildingException)
      • org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(RepositorySystemSession, DependencyRequest) with throw new DependencyResolutionException(result, are); with cause and message being problematic

      Attachments

        1. 1.png
          22 kB
          Michael Osipov
        2. 2.png
          11 kB
          Michael Osipov
        3. Exception hierarchy.png
          26 kB
          Michael Osipov

        Issue Links

          Activity

            People

              sjaranowski Slawomir Jaranowski
              michael-o Michael Osipov
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: