imagej / imagej-maven-plugin

[OBSOLETE] All goals migrated to scijava/scijava-maven-plugin
Other
4 stars 6 forks source link

NPE when copying dependencies for fiji/fiji #31

Closed ctrueden closed 6 years ago

ctrueden commented 6 years ago

One the current fiji/fiji master branch (fiji/fiji@969b2d4254d45af9bbd9200649859e0dc0611d57), running mvn -X -Dimagej.app.directory=Fiji.app fails to copy the dependencies, producing the following failure:

[ERROR] Failed to execute goal net.imagej:imagej-maven-plugin:0.7.0:copy-jars (copy-jars) on project fiji: Execution copy-jars of goal net.imagej:imagej-maven-plugin:0.7.0:copy-jars failed.: NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal net.imagej:imagej-maven-plugin:0.7.0:copy-jars (copy-jars) on project fiji: Execution copy-jars of goal net.imagej:imagej-maven-plugin:0.7.0:copy-jars failed.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    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:309)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
    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 copy-jars of goal net.imagej:imagej-maven-plugin:0.7.0:copy-jars failed.
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:145)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    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:309)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
    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: java.lang.NullPointerException
    at net.imagej.maven.AbstractCopyJarsMojo.installArtifact (AbstractCopyJarsMojo.java:183)
    at net.imagej.maven.AbstractCopyJarsMojo.installArtifact (AbstractCopyJarsMojo.java:139)
    at net.imagej.maven.CopyJarsMojo.execute (CopyJarsMojo.java:188)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    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:309)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
    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)

Using imagej-maven-plugin 0.6.0 does not have this problem, but then does not benefit from the improved dependency handling.

stelfrich commented 6 years ago

I can't reproduce the issue with my setup here, @ctrueden. Does the Fiji instance in your Fiji.app directory have any update sites activate (or something like that)?

The NPE can (at least in theory) only be caused by a JAR file in the imagej.app.directory with a non-SemVer version number or something like that. Could you provide a directory listing of Fiji.app/jars?

ctrueden commented 6 years ago

There were no update sites active. The Fiji.app folder in question was empty. The hope was for the imagej-maven-plugin to create and populate such a folder from scratch.

I can now no longer reproduce either. Not with the commit hash above, and not with the latest master (fiji/fiji@f83d69d08d8e2645531efaa32ab3a575819f8ddf). I am going to add some defensive programming around the areas in the stack trace, in the hopes to proactively avoid this sort of thing in the future.

stelfrich commented 6 years ago

The Fiji.app folder in question was empty. The hope was for the imagej-maven-plugin to create and populate such a folder from scratch.

Oh, I had never thought about that use-case to be honest. In that case the code definitely has to be hardened.

I am going to add some defensive programming around the areas in the stack trace, in the hopes to proactively avoid this sort of thing in the future.

If you don't have the time to be rigorous about it, you can go ahead and mark places that you think need work with TODOs and I can continue working on it. (Just ping me with the branch, I want to avoid duplicate effort)

stelfrich commented 6 years ago

I'll close this for now (since we can't reproduce). Thanks for adding preventive measures, @ctrueden!

ctrueden commented 6 years ago

As I said in https://github.com/imagej/imagej-maven-plugin/pull/34#issuecomment-408955651, I did later manage to reproduce the exception. I was wrong about it being an empty Fiji.app installation. Rather, it was a macOS installation I had been updating over time for years. So it still had the old macosx-java3d folder, with JAR files lacking version suffixes in the name.

I think that #34 is the right fix for this issue, so indeed this issue here can be closed now. Thanks!