[HAP-909] NPE on gather build info Created: 12/Apr/17  Updated: 25/Jun/17  Resolved: 25/Jun/17

Status: Resolved
Project: Jenkins Artifactory Plug-in
Component/s: Maven3
Affects Version/s: 2.9.1, 2.10.3
Fix Version/s: 2.10.4

Type: Bug Priority: Blocker
Reporter: Nikolas Falco Assignee: Eyal Ben Moshe
Resolution: Fixed Votes: 0
Labels: None
Environment:
  • Maven Integration plugin 2.15.1
  • Artifactory Plugin 2.9.1 (try also 2.10.3)
  • Jenkins 2.32.3


 Description   

We are using jenkins 2.32.3 with installed:

  • Maven Integration plugin 2.15.1
  • Artifactory Plugin 2.9.1 (try also 2.10.3)

With a jenkins job of kind Free Style and a build step of kind "Invoke Artifactory Maven" and the same with a Maven Job during deploy of artifacts it fails with a NPE.
I'm build a multi modules maven project, other info on GitHub https://github.com/JFrogDev/build-info/issues/52 (since 2015!!!!)

[main] ERROR org.apache.maven.cli.MavenCli - NullPointerException
java.lang.NullPointerException
	at org.jfrog.build.api.builder.BuildInfoMavenBuilder.mergeModuleDependencies(BuildInfoMavenBuilder.java:400)
	at org.jfrog.build.api.builder.BuildInfoMavenBuilder.mergeModule(BuildInfoMavenBuilder.java:344)
	at org.jfrog.build.api.builder.BuildInfoMavenBuilder.addModule(BuildInfoMavenBuilder.java:301)
	at org.jfrog.build.extractor.maven.BuildInfoRecorder.addFilesToCurrentModule(BuildInfoRecorder.java:486)
	at org.jfrog.build.extractor.maven.BuildInfoRecorder.finalizeAndAddModule(BuildInfoRecorder.java:470)
	at org.jfrog.build.extractor.maven.BuildInfoRecorder.finalizeModule(BuildInfoRecorder.java:398)
	at org.jfrog.build.extractor.maven.BuildInfoRecorder.projectSucceeded(BuildInfoRecorder.java:214)
	at org.apache.maven.lifecycle.internal.DefaultExecutionEventCatapult.fire(DefaultExecutionEventCatapult.java:74)
	at org.apache.maven.lifecycle.internal.DefaultExecutionEventCatapult.fire(DefaultExecutionEventCatapult.java:42)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:126)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)


 Comments   
Comment by Nikolas Falco [ 13/Apr/17 ]

In the past we fall in this NPE randomly but now it happens every build also changing the artifactory plugin version and kind of job (free style/maven style). This block deploy on our organization (licensed) artifactory.

After a long session of debug the issue happens on our "distribution" module (package of kind "pom") placed in a profile (virgo WAS profile). Inside that module we use the maven-assembly-plugin (3.0.0) to generate a zip archive to gather all dependencies.

Follow the `toString()` of the maven project dependencies:

[org.apache.felix:org.apache.felix.ipojo:jar:1.8.4:, org.slf4j:osgi-over-slf4j:jar:1.7.2:, ch.qos.logback:logback-classic:jar:1.0.7:provided, ch.qos.logback:logback-core:jar:1.0.7:provided, org.slf4j:jcl-over-slf4j:jar:1.7.2:provided, org.slf4j:jul-to-slf4j:jar:1.7.2:provided, org.slf4j:log4j-over-slf4j:jar:1.7.2:provided, org.slf4j:slf4j-api:jar:1.7.2:provided, org.apache.servicemix.specs:org.apache.servicemix.specs.jaxb-api-2.2:jar:2.7.0:, org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:jar:1.0.1:compile, org.apache.geronimo.specs:geronimo-activation_1.1_spec:jar:1.1:compile, com.google.inject:guice:jar:4.1.0:, javax.inject:javax.inject:jar:1:compile, aopalliance:aopalliance:jar:1.0:compile, org.eclipse.persistence:javax.persistence:jar:2.1.0:, org.eclipse.persistence:org.eclipse.persistence.oracleddlparser:jar:2.5.2:, org.eclipse.sisu:org.eclipse.sisu.inject:jar:0.3.3:, org.eclipse.persistence:org.eclipse.persistence.oracle:jar:2.5.2:, org.apache.servicemix.bundles:org.apache.servicemix.bundles.javax-inject:jar:1_2:, org.codehaus.jackson:jackson-jaxrs:jar:1.9.2:, org.apache.servicemix.bundles:org.apache.servicemix.bundles.aopalliance:jar:1.0_6:, org.apache.servicemix.bundles:org.apache.servicemix.bundles.xerces:jar:2.11.0_1:, org.codehaus.jackson:jackson-mapper-asl:jar:1.9.2:, org.jboss.spec.javax.annotation:jboss-annotations-api_1.1_spec:jar:1.0.1.Final:provided, org.eclipse.persistence:org.eclipse.persistence.core:jar:2.5.2:, org.apache.servicemix.specs:org.apache.servicemix.specs.activation-api-1.1:jar:2.7.0:, org.eclipse.persistence:org.eclipse.persistence.jpa:jar:2.5.2:, org.joda:joda-money:jar:0.9:, com.sun.jersey.contribs:jersey-multipart:jar:1.19.1:, org.jvnet.mimepull:mimepull:jar:1.9.3:, org.eclipse.persistence:org.eclipse.persistence.oracle.nosql:jar:2.5.2:, org.eclipse.persistence:org.eclipse.persistence.asm:jar:2.5.2:, org.eclipse.persistence:org.eclipse.persistence.jpa.jpql:jar:2.5.2:, com.hazelcast:hazelcast:jar:3.6.4:, org.json:json:jar:20160212:, org.apache.servicemix.specs:org.apache.servicemix.specs.jsr303-api-1.0.0:jar:2.7.0:, com.google.guava:guava:jar:19.0:, org.codehaus.jackson:jackson-xc:jar:1.9.2:, com.thedigitalstack:com.thedigitalstack.org.assertj:jar:1.7.1:, org.hibernate:hibernate-validator:jar:4.3.2.Final:, javax.validation:validation-api:jar:1.0.0.GA:compile, org.apache.servicemix.specs:org.apache.servicemix.specs.scripting-api-1.0:jar:2.7.0:, ...]

As you can see some dependencies, for some reason, has scope set to empty string. Their scope is the default.

The fix in BuildInfoRecorder is easy, in the method `mergeProjectDependencies(Set<Artifact>)` like you do for classifier where you check is if it null and set to empty string, the same you should for scope, set to default if is empty string.

Comment by Eyal Ben Moshe [ 13/Apr/17 ]

Thanks for contributing the fix Nikolas!
https://github.com/JFrogDev/build-info/pull/118

Generated at Sun Oct 20 11:13:32 UTC 2019 using JIRA 7.6.16#76018-sha1:9ed376192612a49536ac834c64177a0fed6290f5.