views:

317

answers:

2

I get a NullPointerException and I don't like it. It is a larger build with several submodules (which differ in their maven config only slightly), for most of the modules it does work, but for some not. Any ideas what the problem might be?

[INFO] [assembly:assembly]
[INFO] Reading assembly descriptor: src/assemble/all.xml
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] null
[INFO] ------------------------------------------------------------------------
[INFO] Trace
java.lang.NullPointerException
at org.apache.maven.artifact.DefaultArtifact.equals(DefaultArtifact.java:358)
at java.util.HashMap.put(HashMap.java:376)
at java.util.HashSet.add(HashSet.java:200)
at java.util.AbstractCollection.addAll(AbstractCollection.java:305)
at org.apache.maven.plugin.assembly.artifact.DefaultDependencyResolver.buildManagedVersionMap(DefaultDependencyResolver.java:160)
at org.apache.maven.plugin.assembly.archive.DefaultAssemblyArchiver.createArchive(DefaultAssemblyArchiver.java:179)
at org.apache.maven.plugin.assembly.mojos.AbstractAssemblyMojo.execute(AbstractAssemblyMojo.java:370)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:678)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:553)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:523)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:371)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:268)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:181)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:356)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 41 seconds
[INFO] Finished at: Fri Jun 19 10:44:03 CEST 2009
[INFO] Final Memory: 32M/99M
[INFO] ------------------------------------------------------------------------
+1  A: 

Looking at line 358 of the head revision, my guess is that something, somewhere has no version defined.

I don't really "know" Maven, but I'd suggest checking your versions carefully. Of course, it's possible that I'm not looking at the same source code as you're using - have a look at the source for your actual version to see what's at DefaultArtifact.java line 358.

Jon Skeet
Your idea brought me on the right track. Indeed I didn't specify a version in the dependency itself, because I moved all version declarations to the dependency management block in the *parent project* and the version apparently doesn't get resolved because it is declared as a range, and not a concrete version. I would consider that as a bug.
Mauli
A: 

And, failing with nullpointer and such Exception is the reason why people have problems with Maven. It's a shame though.

jim