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

MavenMetadataSource#retrieve(MetadataResolutionRequest) does not check for null when reading from project map

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.8.7
    • 3.8.8, 3.9.1, 4.0.0-alpha-5, 4.0.0
    • Core
    • None

    Description

      At Tycho we see

      [ERROR] Internal error: java.lang.NullPointerException: Cannot invoke "org.apache.maven.project.MavenProject.getRemoteArtifactRepositories()" because "project" is null -> [Help 1]
      org.apache.maven.InternalErrorException: Internal error: java.lang.NullPointerException: Cannot invoke "org.apache.maven.project.MavenProject.getRemoteArtifactRepositories()" because "project" is null
          at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:120)
          at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
          at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
          at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
          at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
          at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
          at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke (Method.java:568)
          at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
          at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
          at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
          at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
      Caused by: java.lang.NullPointerException: Cannot invoke "org.apache.maven.project.MavenProject.getRemoteArtifactRepositories()" because "project" is null
          at org.apache.maven.project.artifact.MavenMetadataSource.retrieve (MavenMetadataSource.java:200)
          at org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector.recurse (DefaultLegacyArtifactCollector.java:551)
          at org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector.collect (DefaultLegacyArtifactCollector.java:148)
          at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve (DefaultArtifactResolver.java:504)
          at org.apache.maven.repository.legacy.LegacyRepositorySystem.resolve (LegacyRepositorySystem.java:367)
          at org.eclipse.tycho.osgi.configuration.MavenDependenciesResolverConfigurer.resolve (MavenDependenciesResolverConfigurer.java:106)
          at org.eclipse.tycho.core.shared.MavenDependenciesResolver.resolve (MavenDependenciesResolver.java:58)
          at org.eclipse.tycho.p2.resolver.MavenTargetDefinitionContent.<init> (MavenTargetDefinitionContent.jav
      

      This is because MavenMetadataSource assumes that if the model is read from a workspace model reader there is always a reactor project in the sessions project map, but this is not always true.

      An obvious fix would be to simply assume there are no pomRepositories in such a case, or even query the Model itself with model.getRepositories()

      Attachments

        Activity

          People

            michael-o Michael Osipov
            laeubi Christoph Läubrich
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: