#197210: NPE from DefaultMetadataResolver.resolve in BasicPanelVisual.downloadArchetype

Jesse Glick <[email protected]> Wed, 30 Mar 2011 11:00:54 -0400
Newsgroups gmane.comp.java.netbeans.reviewers
Organization Oracle Corp. / NetBeans
Message-ID <[email protected]>
https://netbeans.org/bugzilla/show_bug.cgi?id=197210
http://hg.netbeans.org/core-main/rev/b50eb95e3fce

Impact: NPE thrown when creating projects from archetype in the local catalog.

Fix: for reasons not fully clear to me, certain Maven 3 operations perhaps using deprecated APIs require a special service to be registered in the Plexus container (and 
do not fail gracefully when it is not). In particular, MavenEmbedder.resolve (used to download artifacts) seems to need this trick. Previously a few places where resolve 
was called set up the special service, but not this one; the fix puts the setup into the resolve method itself instead. (Registering the special service when creating the 
embedder does not work because it has to be done in the same thread as the code that makes use of it.)

Risk: the fix might be mistaken somehow due to lack of understanding of Maven internals. But it seems to work and not cause apparent problems elsewhere.