Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 356725

Summary: Calls to mavenProject.getParent() in BuildParticipants raise an IllegalStateException due to missing context session
Product: z_Archived Reporter: Fred Bricon <fbricon>
Component: m2eAssignee: Project Inbox <m2e.core-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: gregory.amerson, igor
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Fred Bricon CLA 2011-09-05 08:13:25 EDT
Build Identifier: 

Bugs #355292 and #349986 affecting mavenarchiver and m2e-wtp plugins are caused by plugin configurations using project.parent.* properties.

As a matter of fact, calling mavenProject.getParent() in AbstractBuildParticipant.build() causes this exception :

java.lang.IllegalStateException: no context maven session
	at org.eclipse.m2e.core.internal.embedder.ContextRepositorySystemSessionImpl.getSession(ContextRepositorySystemSessionImpl.java:48)
	at org.eclipse.m2e.core.internal.embedder.ContextRepositorySystemSessionImpl.getMirrorSelector(ContextRepositorySystemSessionImpl.java:102)
	at org.sonatype.aether.impl.internal.DefaultRemoteRepositoryManager.aggregateRepositories(DefaultRemoteRepositoryManager.java:139)
	at org.apache.maven.project.ProjectModelResolver.addRepository(ProjectModelResolver.java:119)
	at org.apache.maven.model.building.DefaultModelBuilder.configureResolver(DefaultModelBuilder.java:567)
	at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:306)
	at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:232)
	at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:135)
	at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:98)
	at org.apache.maven.project.MavenProject.getParent(MavenProject.java:359)

As a workaround, the parent projects can be manually loaded in each BuildParticipant implementations, but a proper solution would be to attach (and later detach) each project being built to the current maven session.

The same goes for projects being configured by project configurators.

 	

Reproducible: Always
Comment 1 Igor Fedorenko CLA 2013-06-08 10:42:54 EDT
@fred can you check if latest 1.4 is still affected? This issue may have been addressed as a side effect of introduction of IMavenExecutionContext.
Comment 2 Igor Fedorenko CLA 2013-09-09 22:31:04 EDT
Closing old/stale bugreport
Comment 3 Denis Roy CLA 2021-04-19 13:27:16 EDT
Moved to https://github.com/eclipse-m2e/m2e-core/issues/