Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 366967

Summary: cryptic error message if multiple reactor modules in the same baseDir
Product: z_Archived Reporter: Stephan Herrmann <stephan.herrmann>
Component: TychoAssignee: Jan Sievers <jan.sievers>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: igor, jan.sievers
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Stephan Herrmann CLA 2011-12-16 13:36:24 EST
I'm trying to build an Xtext example using tycho, following this blog post:
http://kthoms.wordpress.com/2010/08/18/building-xtext-projects-with-maven-tycho/
(the example including poms is available at
http://dl.dropbox.com/u/662339/Blogs/XtextTychoExample.zip )

After switching from tycho 0.9 to 0.13 I get the exception pasted below.
While this looks very much like bug 340852 it's not the same because
- it happens in tycho 0.13
- it happens on Windows, too

To reproduce
1. import the projects from XtextTychoExample.zip into a fresh workspace 
   of eclipse-modeling-juno-m4 with Xtext and m2e installed.
2. add the maven nature just to the org.xtext.example.mydsl project
3. edit this projects pom:
   - version.tycho 0.9.0 -> 0.13.0
   - change groupId org.sonatype.tycho to org.eclipse.tycho (2x)
4. select the project and Run as ... Maven test

after downloads have finished you'll see (doens't happen with 0.9.0):

[ERROR] Internal error: java.lang.NullPointerException -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: java.lang.NullPointerException
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:168)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
	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:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:616)
	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: java.lang.NullPointerException
	at org.eclipse.tycho.core.osgitools.EquinoxResolver.assertResolved(EquinoxResolver.java:231)
	at org.eclipse.tycho.core.osgitools.EquinoxResolver.newResolvedState(EquinoxResolver.java:66)
	at org.eclipse.tycho.core.osgitools.OsgiBundleProject.getResolverState(OsgiBundleProject.java:212)
	at org.eclipse.tycho.core.osgitools.OsgiBundleProject.resolveClassPath(OsgiBundleProject.java:154)
	at org.eclipse.tycho.core.resolver.DefaultTychoDependencyResolver.resolveProject(DefaultTychoDependencyResolver.java:96)
	at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.afterProjectsRead(TychoMavenLifecycleParticipant.java:91)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:273)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
	... 11 more

In case you wonder about my positive comment in the mentioned blog:
when I thought I got it to work I had simply used the old tycho version again.
Didn't notice in time before adding that comment.
Comment 1 Igor Fedorenko CLA 2011-12-16 15:41:53 EST
Can you please try Tycho 0.14.0-SNAPSHOT? This NPE is almost certainly caused by a problem with project configuration and 0.14 should provide better diagnostic messages. If this does not help identify the problem, please provide complete standalone sample project that demonstrates the problem.
Comment 2 Stephan Herrmann CLA 2011-12-16 16:06:36 EST
(In reply to comment #1)
> Can you please try Tycho 0.14.0-SNAPSHOT?

How? 

All I get is:
Unresolveable build extension: Plugin org.eclipse.tycho:tycho-maven-plugin:0.14.0-SNAPSHOT or one of its dependencies could not be resolved: Could not find artifact org.eclipse.tycho:tycho-maven-plugin:jar:0.14.0-SNAPSHOT

> This NPE is almost certainly caused
> by a problem with project configuration and 0.14 should provide better
> diagnostic messages. If this does not help identify the problem, please provide
> complete standalone sample project that demonstrates the problem.

A link to the example was provided in comment 0.
Anything unclear in the steps to reproduce?
Comment 3 Igor Fedorenko CLA 2011-12-16 17:25:13 EST
(In reply to comment #2)
> (In reply to comment #1)
> > Can you please try Tycho 0.14.0-SNAPSHOT?
> 
> How? 
> 
> All I get is:
> Unresolveable build extension: Plugin
> org.eclipse.tycho:tycho-maven-plugin:0.14.0-SNAPSHOT or one of its dependencies
> could not be resolved: Could not find artifact
> org.eclipse.tycho:tycho-maven-plugin:jar:0.14.0-SNAPSHOT


Add this snippet to you (parent) pom.xml files

<pluginRepositories>
  <pluginRepository>
    <id>tycho-snapshots</id>
    <url>https://oss.sonatype.org/content/groups/public/</url>
  </pluginRepository>
</pluginRepositories>


> 
> > This NPE is almost certainly caused
> > by a problem with project configuration and 0.14 should provide better
> > diagnostic messages. If this does not help identify the problem, please provide
> > complete standalone sample project that demonstrates the problem.
> 
> A link to the example was provided in comment 0.
> Anything unclear in the steps to reproduce?


Can you provide ready to use example that does not require modifications to pom.xml in order to reproduce the problem?
Comment 4 Stephan Herrmann CLA 2011-12-17 11:17:13 EST
(In reply to comment #3)
> (In reply to comment #2)
> > (In reply to comment #1)
> > > Can you please try Tycho 0.14.0-SNAPSHOT?
> > 
> > How? 
> > 
> [...]
> 
> Add this snippet to you (parent) pom.xml files
> 
> <pluginRepositories>
>   <pluginRepository>
>     <id>tycho-snapshots</id>
>     <url>https://oss.sonatype.org/content/groups/public/</url>
>   </pluginRepository>
> </pluginRepositories>

OK, that helps, but unfortunately it doesn't give a better error message.
Only, it reminds me, that the pom mentions a version of fornax-oaw-m2-plugin
that is no longer available in the snapshot repo. I changed it to
3.3.1-SNAPSHOT, but that's only a side issue here.

> > A link to the example was provided in comment 0.
> > Anything unclear in the steps to reproduce?
> 
> Can you provide ready to use example that does not require modifications to
> pom.xml in order to reproduce the problem?

Actually, I can't. I didn't author the example and it being just a hello-world
example it doesn't have a proper license statement. By attaching it to this 
bug I would wrongly claim that I have the right to publish.
This doesn't preclude anybody from using the example for debugging etc,
but, e.g., you couldn't check it into your source repo (e.g., as a test case).

However, I have full confidence that you can make the few changes to this
simple hello-world style pom:
- change version and groupId of tycho (this is the subject of the bug)
- adjust the version of fornax-oaw-m2-plugin (see above - not needed to
   exhibit the bug in 0.13.0)

I also have some good news for you: from trial-and-error I can narrow 
down the original bug: 
The example contains the following line in its pom:
		<module>./pom-grammar.xml</module>
when I change the directory layout so that parent and module are in
distinct directories, the NPE doesn't occur. Note, that earlier versions
like 0.9.0 had no problem with the directory layout.

After changing the directory layout the example works as expected in
0.14.0-SNAPSHOT, but in 0.13.0 a new problem arises: the fornax
plugin triggers a ClassNotFoundException, that is not raised by either
older nor newer versions.

Which leads me to my last question: where could I learn about the
planned release date for 0.14.0? The canonical project plan URL
http://www.eclipse.org/projects/project-plan.php?projectid=technology.tycho
shows in interesting message :)
Comment 5 Igor Fedorenko CLA 2011-12-17 11:28:39 EST
(In reply to comment #4)
> 
> Which leads me to my last question: where could I learn about the
> planned release date for 0.14.0? The canonical project plan URL
> http://www.eclipse.org/projects/project-plan.php?projectid=technology.tycho
> shows in interesting message :)

There is currently no specific schedule for 0.14.0 release.
Comment 6 Jan Sievers CLA 2011-12-19 06:10:59 EST
(In reply to comment #4)
> I also have some good news for you: from trial-and-error I can narrow 
> down the original bug: 
> The example contains the following line in its pom:
>         <module>./pom-grammar.xml</module>

I am not aware that specifying non-directories as modules is officially supported by maven, see [1]:

"An pom packaged project may aggregate the build of a set of projects by listing them as modules, which are relative directories to those projects."

IIRC Tycho internally keeps track of reactor modules using the module directory as unique handle, so in this case the handle is not unique anymore.

This may appear semi-sane for your scenario (packaging type pom and eclipse-plugin in the same directory with different pom file names), but e.g. two modules of packaging type eclipse-plugin in the same directory won't work because META-INF/MANIFEST.MF is always expected relative to the module directory.

If this is true, I would treat this as WONT_FIX and recommend to change the directory layout so that parent and module are in distinct directories as you already proposed.

We may invest though to detect this scenario and throw a more sensible error message.

[1] http://maven.apache.org/pom.html#Aggregation
Comment 7 Stephan Herrmann CLA 2011-12-20 14:15:52 EST
(In reply to comment #6)
> I am not aware that specifying non-directories as modules is officially
> supported by maven, see [1]:
> 
> "An pom packaged project may aggregate the build of a set of projects by
> listing them as modules, which are relative directories to those projects."

I wasn't aware of that, and obviously the author of the example wasn't
either.

The interesting part is that maven *does* support this setting
(referring to a module by its pom).
And so did tycho versions < 0.13.0.

On this background, fixing the tool to implement the specified semantics
cuts both ways: the tool will be "more correct" but it will break 
existing software out there. The former is a good thing the latter can
be expensive for the business.
Of course each tool provider has to balance this conflict according to
his own judgment (and communicate this decision to the users :) ).

> We may invest though to detect this scenario and throw a more sensible error
> message.

I'd appreciate -- an NPE is never a good error message.
Resolving this bug by an instructive error message sounds fair to me.
Comment 8 Jan Sievers CLA 2012-05-24 11:19:14 EDT
(In reply to comment #7)
> The interesting part is that maven *does* support this setting
> (referring to a module by its pom).

referring to a module by its pom is supported.

multiple modules in the same baseDir are not supported.

proposed change

https://git.eclipse.org/r/#/c/6114/

validates this.
Comment 10 Stephan Herrmann CLA 2012-05-24 17:07:53 EDT
(In reply to comment #8)
> (In reply to comment #7)
> > The interesting part is that maven *does* support this setting
> > (referring to a module by its pom).
> 
> referring to a module by its pom is supported.
> 
> multiple modules in the same baseDir are not supported.

thanks for clarifying!