Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 512326 - NPE with tycho-versions-plugin:update-pom
Summary: NPE with tycho-versions-plugin:update-pom
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Tycho (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 blocker (vote)
Target Milestone: ---   Edit
Assignee: Martin Schreiber CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 515976 (view as bug list)
Depends on:
Blocks: 512100
  Show dependency tree
 
Reported: 2017-02-16 15:03 EST by Sravan Kumar Lakkimsetti CLA
Modified: 2021-04-28 16:53 EDT (History)
3 users (show)

See Also:


Attachments
Log with Tycho 1.0.0 (2.26 MB, text/plain)
2017-02-22 08:53 EST, Sravan Kumar Lakkimsetti CLA
no flags Details
Log with Tycho 0.26.0 (2.32 MB, text/plain)
2017-02-22 08:54 EST, Sravan Kumar Lakkimsetti CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sravan Kumar Lakkimsetti CLA 2017-02-16 15:03:38 EST
Getting NPE when I tried to use tycho 1.0.0 in eclipse build

[ERROR] Failed to execute goal org.eclipse.tycho:tycho-versions-plugin:1.0.0:update-pom (default-cli) on project platform-aggregator: Execution default-cli of goal org.eclipse.tycho:tycho-versions-plugin:1.0.0:update-pom failed. NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.eclipse.tycho:tycho-versions-plugin:1.0.0:update-pom (default-cli) on project platform-aggregator: Execution default-cli of goal org.eclipse.tycho:tycho-versions-plugin:1.0.0:update-pom failed.
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
	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:116)
	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:862)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
	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)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.eclipse.tycho:tycho-versions-plugin:1.0.0:update-pom failed.
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
	... 20 more
Caused by: java.lang.NullPointerException
	at org.eclipse.tycho.versions.engine.VersionChange.hashCode(VersionChange.java:56)
	at java.util.HashMap.hash(HashMap.java:338)
	at java.util.HashMap.put(HashMap.java:611)
	at java.util.HashSet.add(HashSet.java:219)
	at org.eclipse.tycho.versions.engine.VersionsEngine.addVersionChange(VersionsEngine.java:100)
	at org.eclipse.tycho.versions.engine.PomVersionUpdater.apply(PomVersionUpdater.java:107)
	at org.eclipse.tycho.versions.UpdatePomMojo.execute(UpdatePomMojo.java:38)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
	... 21 more
Comment 1 Martin Schreiber CLA 2017-02-17 00:05:51 EST
I debugged into the Tycho Code and the only case this could happen is if you do have an eclipse proudct with a missing version attribute in its .product file.
 
In Tycho 1.0.0 we added support for updating poms for the "eclipse-repository" packaging type (see: Bug: 508293). So I guess that if you are using an older Tycho version it is working because your eclipse prodcut (packaging type "eclipse-repository") is skipped during pom updates but with Tycho 1.0.0 it's trying to update the version of that product pom file.
Please check all your .product files for a missing version attribute

The version is an attribute of the root xml element in the .product file:
<product uid="foo.bar" version="1.0.0.qualifier" useFeatures="true" includeLaunchers="false">

The Bug here is that we should fail the build with an appropriate error message if the version attribute is missing.
Comment 2 Martin Schreiber CLA 2017-02-17 00:51:19 EST
Sorry, there is another case. When the .product file could not be found. Tycho assumes, that the .product file does have the name <artifactId>.product. 

Looking into your code I see that the following product files do not follow that convention:

eclipse.platform.releng.tychoeclipsebuilder/platform.sdk/platform.sdk.product
eclipse.platform.releng.tychoeclipsebuilder/sdk/sdk.product
eclipse.platform.releng.tychoeclipsebuilder/rcp.config/config.product
eclipse.platform.releng.tychoeclipsebuilder/equinox.starterkit.product/EclipseRTOSGiStarterKit.product
eclipse.platform.releng.tychoeclipsebuilder/platform/platform.product
eclipse.platform.releng.tychoeclipsebuilder/rcp/rcp.product
eclipse.platform.releng.tychoeclipsebuilder/rcp.sdk/rcp.sdk.product

If it's an option for you, rename your product files to match <artifactid>.product.

Maybe we must be more flexible when looking up the product file:
E.g. first look for a <artifactId>.product file, if it's not there take the first .product file found in that directory and fail if there is no product file there.
Comment 3 Eclipse Genie CLA 2017-02-17 01:58:08 EST
New Gerrit change created: https://git.eclipse.org/r/91340
Comment 4 Sravan Kumar Lakkimsetti CLA 2017-02-22 08:28:14 EST
(In reply to Martin Schreiber from comment #2)
> Sorry, there is another case. When the .product file could not be found.
> Tycho assumes, that the .product file does have the name
> <artifactId>.product. 
> 
> Looking into your code I see that the following product files do not follow
> that convention:
> 
> eclipse.platform.releng.tychoeclipsebuilder/platform.sdk/platform.sdk.product
> eclipse.platform.releng.tychoeclipsebuilder/sdk/sdk.product
> eclipse.platform.releng.tychoeclipsebuilder/rcp.config/config.product
> eclipse.platform.releng.tychoeclipsebuilder/equinox.starterkit.product/
> EclipseRTOSGiStarterKit.product
> eclipse.platform.releng.tychoeclipsebuilder/platform/platform.product
> eclipse.platform.releng.tychoeclipsebuilder/rcp/rcp.product
> eclipse.platform.releng.tychoeclipsebuilder/rcp.sdk/rcp.sdk.product
> 
> If it's an option for you, rename your product files to match
> <artifactid>.product.
> 
> Maybe we must be more flexible when looking up the product file:
> E.g. first look for a <artifactId>.product file, if it's not there take the
> first .product file found in that directory and fail if there is no product
> file there.

I tried renaming the product files. even after renaming I am still getting the same NPE.
Comment 5 Sravan Kumar Lakkimsetti CLA 2017-02-22 08:53:29 EST
Created attachment 266940 [details]
Log with Tycho 1.0.0
Comment 6 Sravan Kumar Lakkimsetti CLA 2017-02-22 08:54:21 EST
Created attachment 266941 [details]
Log with Tycho 0.26.0
Comment 7 Sravan Kumar Lakkimsetti CLA 2017-02-22 08:55:01 EST
These logs are generated with .product filenames changed.
Comment 8 Martin Schreiber CLA 2017-02-22 09:53:13 EST
The code in 1.0.0 assumes for packaging type "eclipse-repository", that there is a product file named <artifactid>.product, regardles if it is a product or an eclipse update site (="eclipse-repository" packaging type + a category.xml).

You do have both scenarios. The product files do have a different name, and now your build is failing because you also have eclipse update sites without a product definition file.

This are the update sites that causes the NPE now:

eclipse.platform.releng.tychoeclipsebuilder/java9patch47/eclipse.releng.repository.java9patch

eclipse.platform.releng.tychoeclipsebuilder/eclipse.platform.repository

eclipse.platform.releng.tychoeclipsebuilder/java9patch46/eclipse.releng.repository.java9patch


The gerrit change noted above contains a fix for all that cases by:
_Skipping version update when no product file could be found (eclipse update site case, because in the category.xml there is no information about a version)
_Use the <artifact>.product file if present
_Use the *.product file if only one is resent
_Skip version update if more than one product files are present

If you can't wait for next Tycho release, a dirty workarround might work: The product file is used to extract the version, that will be set in the pom. 
If you add a <artifactId>.product file into the eclipse update site directories, the POM Updater will be satisfied.
The product file could be just with the root element and a version attribute:
<product version="4.7.0.qualifier" />

This version will be used to set the version in the pom file.
Comment 10 Sravan Kumar Lakkimsetti CLA 2017-02-23 05:38:57 EST
(In reply to Martin Schreiber from comment #8)
> The code in 1.0.0 assumes for packaging type "eclipse-repository", that
> there is a product file named <artifactid>.product, regardles if it is a
> product or an eclipse update site (="eclipse-repository" packaging type + a
> category.xml).
> 
> You do have both scenarios. The product files do have a different name, and
> now your build is failing because you also have eclipse update sites without
> a product definition file.
> 
> This are the update sites that causes the NPE now:
> 
> eclipse.platform.releng.tychoeclipsebuilder/java9patch47/eclipse.releng.
> repository.java9patch
> 
> eclipse.platform.releng.tychoeclipsebuilder/eclipse.platform.repository
> 
> eclipse.platform.releng.tychoeclipsebuilder/java9patch46/eclipse.releng.
> repository.java9patch
> 
> 
> The gerrit change noted above contains a fix for all that cases by:
> _Skipping version update when no product file could be found (eclipse update
> site case, because in the category.xml there is no information about a
> version)
> _Use the <artifact>.product file if present
> _Use the *.product file if only one is resent
> _Skip version update if more than one product files are present
> 
> If you can't wait for next Tycho release, a dirty workarround might work:
> The product file is used to extract the version, that will be set in the
> pom. 
> If you add a <artifactId>.product file into the eclipse update site
> directories, the POM Updater will be satisfied.
> The product file could be just with the root element and a version attribute:
> <product version="4.7.0.qualifier" />
> 
> This version will be used to set the version in the pom file.

Please let me know when is the next tycho release. In the mean time is it possible for me to use snapshot version? if yes please let me know
Comment 11 Martin Schreiber CLA 2017-02-23 06:22:52 EST
Yes it is possible to use a Tycho Snapshot [1] by adding the snapshot repository into your parent pom. Current Snapshot version: 1.1.0-SNAPSHOT

[1] https://wiki.eclipse.org/Getting_Tycho
Comment 12 Sravan Kumar Lakkimsetti CLA 2017-02-23 07:18:40 EST
(In reply to Martin Schreiber from comment #11)
> Yes it is possible to use a Tycho Snapshot [1] by adding the snapshot
> repository into your parent pom. Current Snapshot version: 1.1.0-SNAPSHOT
> 
> [1] https://wiki.eclipse.org/Getting_Tycho

I tried update-pom from snapshot. it is working. I will do a full build with snapshot and update the bug with results
Comment 13 Jan Sievers CLA 2017-05-03 04:58:04 EDT
*** Bug 515976 has been marked as a duplicate of this bug. ***