Maven 2 & 3

NullPointerException when eclipse jars are marked as "provided"

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 2.0.6
  • Fix Version/s: 2.0.7
  • Component/s: Dependencies
  • Labels:
    None
  • Number of attachments :
    2

Description

When a pde artifact is built that transitively depends on some eclipse jars, and an attempt is made to filter out those eclipse jars by marking the scope as provided, maven NPEs during eclipse:eclipse as follows:

[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] null
[INFO] ------------------------------------------------------------------------
[INFO] Trace
java.lang.NullPointerException
at org.apache.maven.artifact.resolver.DefaultArtifactCollector.recurse(DefaultArtifactCollector.java:164)
at org.apache.maven.artifact.resolver.DefaultArtifactCollector.recurse(DefaultArtifactCollector.java:334)
at org.apache.maven.artifact.resolver.DefaultArtifactCollector.recurse(DefaultArtifactCollector.java:334)
at org.apache.maven.artifact.resolver.DefaultArtifactCollector.recurse(DefaultArtifactCollector.java:334)
at org.apache.maven.artifact.resolver.DefaultArtifactCollector.recurse(DefaultArtifactCollector.java:334)
at org.apache.maven.artifact.resolver.DefaultArtifactCollector.recurse(DefaultArtifactCollector.java:334)
at org.apache.maven.artifact.resolver.DefaultArtifactCollector.collect(DefaultArtifactCollector.java:75)
at org.apache.maven.plugin.ide.AbstractIdeSupportMojo.doDependencyResolution(AbstractIdeSupportMojo.java:447)
at org.apache.maven.plugin.ide.AbstractIdeSupportMojo.execute(AbstractIdeSupportMojo.java:398)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:443)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:493)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:463)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:278)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:334)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:125)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:272)
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:585)
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: 6 seconds
[INFO] Finished at: Tue Jun 05 19:00:22 BST 2007
[INFO] Final Memory: 7M/13M
[INFO] ------------------------------------------------------------------------

  1. npe-fix.patch
    19/Jun/07 5:33 AM
    1 kB
    Graham Leggett
  2. pom.xml
    06/Jun/07 11:44 AM
    8 kB
    Graham Leggett

Activity

Hide
Jason van Zyl added a comment -

Provide a POM we can use. A stack trace is not enough for us to reproduce the problem.

Show
Jason van Zyl added a comment - Provide a POM we can use. A stack trace is not enough for us to reproduce the problem.
Hide
Brett Porter added a comment -

I think this should be reopened, but would still request more information. I don't believe the scope is related - by looking at the code causing the NPE it is clearly that it is unable match a range against a set of versions (we should add another guard to this line of code and deal with it appropriately)

Show
Brett Porter added a comment - I think this should be reopened, but would still request more information. I don't believe the scope is related - by looking at the code causing the NPE it is clearly that it is unable match a range against a set of versions (we should add another guard to this line of code and deal with it appropriately)
Hide
Graham Leggett added a comment -

Unfortunately the pom file used is a child of an aggregated build, which depends on another aggregated build, so apart from eyeballing the pom file it's unlikely to be much direct help. Will attach it regardless.

Looking at the code, the NPE happens at this line:

List previousNodes = (List) resolvedArtifacts.get( key );

which if I am reading correctly, should only happen if the variable resolvedArtifacts is set to null. Following the trace back, resolvedArtifacts gets set in just one place: org.apache.maven.artifact.resolver.DefaultArtifactCollector.collect(DefaultArtifactCollector.java:66) like this:

Map resolvedArtifacts = new HashMap();

I am struggling to get this to work in a debugger, once I figure that out I'll be able to step through this code and get a clearer picture of what is going on.

Show
Graham Leggett added a comment - Unfortunately the pom file used is a child of an aggregated build, which depends on another aggregated build, so apart from eyeballing the pom file it's unlikely to be much direct help. Will attach it regardless. Looking at the code, the NPE happens at this line: List previousNodes = (List) resolvedArtifacts.get( key ); which if I am reading correctly, should only happen if the variable resolvedArtifacts is set to null. Following the trace back, resolvedArtifacts gets set in just one place: org.apache.maven.artifact.resolver.DefaultArtifactCollector.collect(DefaultArtifactCollector.java:66) like this: Map resolvedArtifacts = new HashMap(); I am struggling to get this to work in a debugger, once I figure that out I'll be able to step through this code and get a clearer picture of what is going on.
Hide
Graham Leggett added a comment -

Sorry, I'm being a moron - the debugger was pointing at the wrong code.

The line that is NPEing is this one:

164: resetArtifact.selectVersion( resetArtifact.getVersionRange().matchVersion(
resetArtifact.getAvailableVersions() ).toString() );

Or, to be more specific, the following statement returns null:

resetArtifact.getVersionRange().matchVersion(
resetArtifact.getAvailableVersions() )

which is in turn not handled.

Digging deeper, if I evaluate the expression resetArtifact.getAvailableVersions() it evaluates to the single entry [3.2.0]. If I evaluate resetArtifact.getVersionRange().toString() it evaluates to "".

Based on this it seems the case of where the list of available versions is not inside the version range, this case in currently unhandled. I don't know what the correct way would be to handle this, does anyone know what this code is trying to do?

Show
Graham Leggett added a comment - Sorry, I'm being a moron - the debugger was pointing at the wrong code. The line that is NPEing is this one: 164: resetArtifact.selectVersion( resetArtifact.getVersionRange().matchVersion( resetArtifact.getAvailableVersions() ).toString() ); Or, to be more specific, the following statement returns null: resetArtifact.getVersionRange().matchVersion( resetArtifact.getAvailableVersions() ) which is in turn not handled. Digging deeper, if I evaluate the expression resetArtifact.getAvailableVersions() it evaluates to the single entry [3.2.0]. If I evaluate resetArtifact.getVersionRange().toString() it evaluates to "". Based on this it seems the case of where the list of available versions is not inside the version range, this case in currently unhandled. I don't know what the correct way would be to handle this, does anyone know what this code is trying to do?
Hide
Graham Leggett added a comment -

The attached patch fixes the NullPointerException.

Show
Graham Leggett added a comment - The attached patch fixes the NullPointerException.
Hide
wing-tung Leung added a comment -

We encountered the some NPE using maven 2.0.6 without exactly knowing the reason. Just upgrading 2.0.7 fixed our problem.

Maybe ok to close this issue?

Show
wing-tung Leung added a comment - We encountered the some NPE using maven 2.0.6 without exactly knowing the reason. Just upgrading 2.0.7 fixed our problem. Maybe ok to close this issue?
Hide
Graham Leggett added a comment -

v2.0.7 fixes the issue for me.

Show
Graham Leggett added a comment - v2.0.7 fixes the issue for me.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: