Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

install-node-and-yarn causes NullPointerException for invalid yarn version #532

Open
tf opened this issue Dec 6, 2016 · 5 comments
Open

Comments

@tf
Copy link

tf commented Dec 6, 2016

I forgot the leading v in the yarn version:

<execution>
  <id>install node and yarn</id>
  <goals>
    <goal>install-node-and-yarn</goal>
  </goals>
  <phase>generate-resources</phase>
    <configuration>
      <nodeVersion>v5.7.1</nodeVersion>
      <yarnVersion>0.18.0</yarnVersion>
    </configuration>
</execution>

This causes a NullPointerException:

https://gist.github.com/tf/807716d2d18123da90d6d5e6aaf17d69

If yarn already has been installed, the version is detected correctly. It would be nice, if the error message stated that the specified version cannot be found.

Plugin Version 1.3
Ubuntu 16.04

@styner9
Copy link

styner9 commented Dec 7, 2016

(I am not a contributor, so maybe my advice is wrong)
check version format : v required
https://github.com/eirslett/frontend-maven-plugin#installing-node-and-yarn

@tf
Copy link
Author

tf commented Dec 7, 2016

@styner9 thanks for your answer. I'm well aware now that the v is required. I just think, the error message that is printed in this case could be improved to make this clearer.

@styner9
Copy link

styner9 commented Dec 7, 2016

@tf I totally agree with you! I expect that it will improve soon.
(As I said before, I am just a watcher.)

@eirslett
Copy link
Owner

eirslett commented Dec 7, 2016

If you have time to send a PR that adds a better error message, feel free, I would welcome it :-)

@yamass
Copy link
Contributor

yamass commented Jan 8, 2017

I just had the same problem as the OP. The problem for me was not the error message but the fact that it is not displayed. Instead, a NullPointerException is thrown:

	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:483)
	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)
	at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution install node and yarn of goal com.github.eirslett:frontend-maven-plugin:1.4-SNAPSHOT:install-node-and-yarn failed.
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
	... 21 more
Caused by: java.lang.NullPointerException
	at com.github.eirslett.maven.plugins.frontend.mojo.MojoUtils.toMojoFailureException(MojoUtils.java:27)
	at com.github.eirslett.maven.plugins.frontend.mojo.AbstractFrontendMojo.execute(AbstractFrontendMojo.java:97)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
	... 22 more

This was because in MojoUtils.java:27 e.getCause() returned null.

This apparently only happens on the first build (neither node nor node_modules are present).

I'll send you a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants