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

NullPointerException thrown by DefaultExceptionHandler, obscuring underlying ProjectBuildingException

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Incomplete
    • Affects Version/s: 3.0.4
    • Fix Version/s: None
    • Component/s: Errors
    • Labels:
      None
    • Environment:
      Linux 2.6.32-5-686

      Description

      Running the Maven build with -X, I get the following stack trace from Maven:

      [ERROR] Error executing Maven.
      java.lang.NullPointerException
      	at org.apache.maven.exception.DefaultExceptionHandler.handle(DefaultExceptionHandler.java:104)
      	at org.apache.maven.exception.DefaultExceptionHandler.handleException(DefaultExceptionHandler.java:89)
      	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:553)
      	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
      	at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
      	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:597)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
      

      The underlying problem in my build is a custom plugin that fails to resolve an artifact. I can solve this, but clearly NPEs in Maven's error handling code is not good. I can see the original exception by putting in an explicit try-catch in the plugin:

      org.apache.maven.project.ProjectBuildingException: Error resolving project artifact: Could not find artifact org.oclc.merlins.service-directory:service-directory-api:pom:1.16.0 for project org.oclc.merlins.service-directory:service-directory-api:pom:1.16.0
      	at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:296)
      	at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:267)
      	at org.apache.maven.project.ProjectBuilder$build.call(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
      	at org.oclc.build.tools.mojo.MavenContext.getMavenContext(MavenContext.groovy:374)
      	at org.oclc.build.tools.mojo.MavenContext$getMavenContext.call(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
      	at org.oclc.build.tools.api.plugin.check.CheckApiMojo.execute(CheckApiMojo.groovy:120)
      	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
      	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
      	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
      	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
      	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
      	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
      	at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
      	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
      	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
      	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
      	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
      	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
      	at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
      	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:597)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
      Caused by: org.sonatype.aether.resolution.ArtifactResolutionException: Could not find artifact org.oclc.merlins.service-directory:service-directory-api:pom:1.16.0
      	at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:538)
      	at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:216)
      	at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:193)
      	at org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:286)
      	at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:285)
      	... 32 more
      Caused by: org.sonatype.aether.transfer.ArtifactNotFoundException: Could not find artifact org.oclc.merlins.service-directory:service-directory-api:pom:1.16.0
      	at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:528)
      	... 36 more
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                alex.mcmanus@oclc.org Alex McManus
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: