Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 345139 - Update Project Configuration silently fails if parent project does not have Maven nature
Summary: Update Project Configuration silently fails if parent project does not have M...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: m2e (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Igor Fedorenko CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-09 09:36 EDT by Kristoffer Peterhänsel CLA
Modified: 2021-04-19 13:24 EDT (History)
2 users (show)

See Also:


Attachments
Example project (2.94 KB, application/octet-stream)
2011-05-09 09:36 EDT, Kristoffer Peterhänsel CLA
no flags Details
proposed fix (2.91 KB, patch)
2011-05-14 22:33 EDT, Igor Fedorenko CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kristoffer Peterhänsel CLA 2011-05-09 09:36:33 EDT
Created attachment 195068 [details]
Example project

It seems that in the latest milestone and nightly builds of m2e it will silently fail an Update Project Configuration, if there are multi-module projects where the main project does not have the Maven nature.

The exception thrown in the Eclipse error log is this: 

java.lang.ClassCastException: org.eclipse.core.internal.resources.Folder cannot be cast to org.eclipse.core.resources.IProject
at org.eclipse.m2e.core.ui.internal.dialogs.UpdateDepenciesDialog.getMavenCodebases(UpdateDepenciesDialog.java:327)
at org.eclipse.m2e.core.ui.internal.dialogs.UpdateDepenciesDialog.createDialogArea(UpdateDepenciesDialog.java:192)
at org.eclipse.jface.dialogs.TitleAreaDialog.createContents(TitleAreaDialog.java:155)
at org.eclipse.jface.window.Window.create(Window.java:431)
at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089)
at org.eclipse.jface.window.Window.open(Window.java:790)
at org.eclipse.m2e.core.ui.internal.actions.UpdateConfigurationAction.run(UpdateConfigurationAction.java:30)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
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.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
at org.eclipse.equinox.launcher.Main.main(Main.java:1384)


I *think* the problem is exactly what it says in the JavaDoc for IWorkspaceRoot#getContainerForLocation:
"Warning: This method ignores linked resources and their children. Since linked resources may overlap other resources, a unique mapping from a file system location to a single resource is not guaranteed. To find all resources for a given location, including linked resources, use the method findContainersForLocation."

Although I haven't spend any time figuring out why it don't happen if the main project is also Maven enabled.
Comment 1 Igor Fedorenko CLA 2011-05-14 22:33:52 EDT
Created attachment 195656 [details]
proposed fix
Comment 2 Matthew Piggott CLA 2011-05-16 11:48:52 EDT
+1 tested the patch and the fix looks correct to me.
Comment 3 Igor Fedorenko CLA 2011-05-16 22:31:17 EDT
fixed.
Comment 4 Denis Roy CLA 2021-04-19 13:24:38 EDT
Moved to https://github.com/eclipse-m2e/m2e-core/issues/