Maven Assembly Plugin fails with Clover

Still need help?

The Atlassian Community is here for you.

Ask the community

Symptoms

  • project is using the maven-assembly-plugin
  • project is a multi-module Maven project and is built by Bamboo
  • build fails when the automatic Clover integration in Bamboo is enabled

 

Build log contains errors like the following:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.3:single (make-assembly) on project xyz: Execution make-assembly of goal org.apache.maven.plugins:maven-assembly-plugin:2.3:single failed. NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.3:single (make-assembly) on project xyz: Execution make-assembly of goal org.apache.maven.plugins:maven-assembly-plugin:2.3:single failed.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225)
    ...

Caused by: org.apache.maven.plugin.PluginExecutionException: Execution make-assembly of goal org.apache.maven.plugins:maven-assembly-plugin:2.3:single failed.
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110)
    ... 

Caused by: java.lang.NullPointerException
    at org.codehaus.plexus.components.io.resources.PlexusIoURLResource.getContents(PlexusIoURLResource.java:38)
    ... 

or

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.4:single (make-assembly) on project xyz: Failed to create assembly: Error creating assembly archive withdep: Problem creating jar: jar:file:/opt/bamboo-agent-home/xml-data/build-dir/PROJ-PLAN-JOB/target/xyz-1.0.0-SNAPSHOT.jar!/instrumentation.ser -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.4:single (make-assembly) on project xyz: Failed to create assembly: Error creating assembly archive withdep: Problem creating jar: jar:file:/opt/bamboo-agent-home/xml-data/build-dir/PROJ-PLAN-JOB/target/xyz-1.0.0-SNAPSHOT.jar!/instrumentation.ser
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    ...

Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to create assembly: Error creating assembly archive withdep: Problem creating jar: jar:file:/opt/bamboo-agent-home/xml-data/build-dir/PROJ-PLAN-JOB/target/xyz-1.0.0-SNAPSHOT.jar!/instrumentation.ser
    at org.apache.maven.plugin.assembly.mojos.AbstractAssemblyMojo.execute(AbstractAssemblyMojo.java:495)
    ... 

Caused by: org.apache.maven.plugin.assembly.archive.ArchiveCreationException: Error creating assembly archive withdep: Problem creating jar: jar:file:/opt/bamboo-agent-home/xml-data/build-dir/PROJ-PLAN-JOB/target/xyz-1.0.0-SNAPSHOT.jar!/instrumentation.ser
    at org.apache.maven.plugin.assembly.archive.DefaultAssemblyArchiver.createArchive(DefaultAssemblyArchiver.java:190)
    ... 

Caused by: org.codehaus.plexus.archiver.ArchiverException: Problem creating jar: jar:file:/opt/bamboo-agent-home/xml-data/build-dir/PROJ-PLAN-JOB/target/xyz-1.0.0-SNAPSHOT.jar!/instrumentation.ser
    at org.codehaus.plexus.archiver.AbstractArchiver.createArchive(AbstractArchiver.java:927)
    ... 

Caused by: java.io.IOException: jar:file:/opt/bamboo-agent-home/xml-data/build-dir/PROJ-PLAN-JOB/target/xyz-1.0.0-SNAPSHOT.jar!/instrumentation.ser
    at org.codehaus.plexus.components.io.resources.PlexusIoURLResource.getContents(PlexusIoURLResource.java:38)
    ... 

 

Cause

A problem is related with BAM-13208 - Getting issue details... STATUS .

When automatic Clover integration is selected, all Maven tasks defined in a Job are enhanced by new set of goals/phases (like "clean clover:setup verify clover:aggregate clover:clover") which are being appended at the end of the original Maven command defined in the task(s). Due to a fact that:

  • Maven performs build module-by-module and not phase-by-phase (for example: if a project has module A and module B and you run 'mvn clean package' then Maven runs first 'clean package' for module A, and next 'clean package' for module B) and that
  • Clover's automatic integration in Bamboo calls the "verify" phase

it causes that the same build phases are called twice - once without Clover and once with Clover. In our example, goals "mvn clean package" are changed to "mvn clean package clean clover:setup verify clover:aggregate clover:clover".

 

In this case, a maven-assembly-plugin running in a build phase without Clover (i.e. before the clover:setup) is trying to access resources from dependent modules, which have been already instrumented by Clover (i.e. created in the phase after clover:setup). As a consequence, Maven Assembly Plugin fails accessing files like:

**/instrumentation.ser
**/groverconfig*/*
**/classes/**/*$__CLR*.class

 

Solution

In order to avoid such problems, Maven shall not run the same build phase twice.

You have to configure manual Clover integration and modify the "Goals" field in a Maven Task(s). In case when your original goals are:

mvn clean <other goals or phases>

 

they should be changed to:

mvn clean clover:setup <other goals or phases> clover:aggregate clover:clover

 

Notes

The NullPointerException thrown by maven-assembly-plugin may have also a different cause. There is an NPE bug affecting version 2.3.0, which has been fixed in version 2.4.0. See the http://jira.codehaus.org/browse/MASSEMBLY-626 for more details.

Last modified on Dec 8, 2015

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.