Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 359855 - ArchetypeArtifactManager fails to resolve local archetypes properly
Summary: ArchetypeArtifactManager fails to resolve local archetypes properly
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: m2e (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Fred Bricon CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 385273 (view as bug list)
Depends on:
Blocks: 371775
  Show dependency tree
 
Reported: 2011-10-04 11:19 EDT by Fred Bricon CLA
Modified: 2021-04-19 13:26 EDT (History)
1 user (show)

See Also:


Attachments
Archetype to unzip and install in the local repo (7.10 KB, application/x-zip-compressed)
2011-10-04 11:20 EDT, Fred Bricon CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Fred Bricon CLA 2011-10-04 11:19:45 EDT
Build Identifier: 20110916-0149

When you try to create a project from an archetype existing only in the local repository, 
ArchetypeArtifactManager.isFileSetArchetype(...) always returns false, due to un underlying artifact resolution exception : 

Caused by: java.lang.NullPointerException: null
	at org.sonatype.aether.impl.internal.DefaultMetadataResolver.resolve(DefaultMetadataResolver.java:283) ~[aether-impl-1.11.jar:na]
	at org.sonatype.aether.impl.internal.DefaultMetadataResolver.resolveMetadata(DefaultMetadataResolver.java:177) ~[aether-impl-1.11.jar:na]
	at org.apache.maven.repository.internal.DefaultVersionResolver.resolveVersion(DefaultVersionResolver.java:211) ~[maven-aether-provider-3.0.3.jar:3.0.3]
	at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:276) ~[aether-impl-1.11.jar:na]
	at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:220) ~[aether-impl-1.11.jar:na]
	at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:197) ~[aether-impl-1.11.jar:na]
	at org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:323) ~[aether-impl-1.11.jar:na]
	at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:213) ~[maven-compat-3.0.3.jar:3.0.3]
	at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:157) ~[maven-compat-3.0.3.jar:3.0.3]
	at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:525) ~[maven-compat-3.0.3.jar:3.0.3]
	at org.apache.maven.archetype.downloader.DefaultDownloader.download(DefaultDownloader.java:55) ~[archetype-common-2.0-alpha-4.jar:2.0-alpha-4]
	at org.apache.maven.archetype.common.DefaultArchetypeArtifactManager.getArchetypeFile(DefaultArchetypeArtifactManager.java:98) ~[archetype-common-2.0-alpha-4.jar:2.0-alpha-4]
	at org.apache.maven.archetype.common.DefaultArchetypeArtifactManager.isFileSetArchetype(DefaultArchetypeArtifactManager.java:227) ~[archetype-common-2.0-alpha-4.jar:2.0-alpha-4]
	at org.eclipse.m2e.core.ui.internal.wizards.MavenProjectWizardArchetypeParametersPage$9.run(MavenProjectWizardArchetypeParametersPage.java:397) ~[org.eclipse.m2e.core.ui_1.0.100.20110804-1717.jar:na]
	at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464) ~[org.eclipse.jface_3.7.0.I20110522-1430.jar:na]

Since the archetype is not resolved, The Properties table from MavenProjectWizardArchetypeParametersPage is not populated with the archetype required properties.
Ultimately, project creation fails because of these missing required properties.

Note that, sometimes, the properties table get filled up, after creating a few projects, while switching archetypes. It seems it's caused by the call to setArchetype() (if archetype has changed, properties table is re-populated)  

Reproducible: Always

Steps to Reproduce:
1. unzip and install the attached archetype (someproject-archetype)
2. in m2e, create a new maven project
3. choose someproject-archetype in the default local catalog (use snapshots)
4. click next
5. Assert the property "name" having the value "my project" is displayed <- fails
Comment 1 Fred Bricon CLA 2011-10-04 11:20:39 EDT
Created attachment 204516 [details]
Archetype to unzip and install in the local repo
Comment 2 Fred Bricon CLA 2012-07-17 05:15:25 EDT
*** Bug 385273 has been marked as a duplicate of this bug. ***
Comment 3 Fred Bricon CLA 2012-08-16 18:01:20 EDT
Fixed with http://git.eclipse.org/c/m2e/m2e-core.git/commit/?id=052c1ee493b0c6be9738166442501f605a3bd45c. Highlight of the fix is calling LegacySupport to provide a proper maven session to the archetyper resolver.

Using the actual remote repo of the archetype, properly configured, also fixes bug 371775. 

Tests : https://github.com/sonatype/m2e-core-tests/commit/1ba7b2efc09da1a882d6356d40edbab2063ae33a
Comment 4 Denis Roy CLA 2021-04-19 13:26:17 EDT
Moved to https://github.com/eclipse-m2e/m2e-core/issues/