Uploaded image for project: 'Maven Assembly Plugin'
  1. Maven Assembly Plugin
  2. MASSEMBLY-306

Dependency resolution fails with an NPE for a provided dependency with a fixed version

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 2.2-beta-2
    • 2.2-beta-3
    • None
    • None
    • Maven 2.0.8, Java 1.6.0_03-b05

    Description

      A POM like this:

      <?xml version="1.0" encoding="UTF-8"?><project>
      <modelVersion>4.0.0</modelVersion>
      <groupId>maven-test</groupId>
      <artifactId>maven-test</artifactId>
      <name>maven-test</name>
      <version>1.0-SNAPSHOT</version>
      <url>http://maven.apache.org</url>
      <dependencies>
      <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>[1.2.13]</version>
      <scope>provided</scope>
      </dependency>
      </dependencies>
      <build>
      <plugins>
      <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-assembly-plugin</artifactId>
      <version>2.2-beta-2</version>
      <configuration>
      <descriptorRefs>
      <descriptorRef>jar-with-dependencies</descriptorRef>
      </descriptorRefs>
      <archive>
      <manifest>
      <mainClass>ning.dashboard.DashboardServer</mainClass>
      </manifest>
      </archive>
      </configuration>
      <executions>
      <execution>
      <id>make-assembly</id>
      <phase>package</phase>
      <goals>
      <goal>attached</goal>
      </goals>
      </execution>
      </executions>
      </plugin>
      </plugins>
      </build>
      </project>

      fails with this error:

      [INFO] Processing DependencySet (output=)
      [INFO] ------------------------------------------------------------------------
      [ERROR] FATAL ERROR
      [INFO] ------------------------------------------------------------------------
      [INFO] version was null for log4j:log4j
      [INFO] ------------------------------------------------------------------------
      [INFO] Trace
      java.lang.NullPointerException: version was null for log4j:log4j
      at org.apache.maven.artifact.DefaultArtifact.getBaseVersion(DefaultArtifact.java:362)
      at org.apache.maven.artifact.DefaultArtifact.getId(DefaultArtifact.java:225)
      at org.apache.maven.shared.artifact.filter.ScopeArtifactFilter.include(ScopeArtifactFilter.java:142)
      at org.apache.maven.project.artifact.MavenMetadataSource.createArtifacts(MavenMetadataSource.java:345)
      at org.apache.maven.plugin.assembly.artifact.DefaultDependencyResolver.resolveDependencies(DefaultDependencyResolver.java:123)
      at org.apache.maven.plugin.assembly.archive.task.AddDependencySetsTask.resolveDependencyArtifacts(AddDependencySetsTask.java:205)
      at org.apache.maven.plugin.assembly.archive.task.AddDependencySetsTask.addDependencySet(AddDependencySetsTask.java:132)
      at org.apache.maven.plugin.assembly.archive.task.AddDependencySetsTask.execute(AddDependencySetsTask.java:116)
      at org.apache.maven.plugin.assembly.archive.phase.DependencySetAssemblyPhase.execute(DependencySetAssemblyPhase.java:74)
      at org.apache.maven.plugin.assembly.archive.DefaultAssemblyArchiver.createArchive(DefaultAssemblyArchiver.java:129)
      at org.apache.maven.plugin.assembly.mojos.AbstractAssemblyMojo.execute(AbstractAssemblyMojo.java:322)
      at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:447)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:480)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:459)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:278)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:333)
      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:126)
      at org.apache.maven.cli.MavenCli.main(MavenCli.java:282)
      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.classworlds.Launcher.launchEnhanced(Launcher.java:315)
      at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
      at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
      at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

      As far as I can see in the code, the problem is twofold:

      • the DefaultArtifact does not set a recommended version even though there is a single version for the artifact (the version is not only recommended but forced)
      • the assembly plugin does not handle the forced version properly

      Attachments

        Issue Links

          Activity

            People

              jdcasey John Dennis Casey
              tomdz Thomas Dudziak
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: