views:

196

answers:

2

Does anyone notice that after enabling Maven dependency management in Eclipse for a project, the refactor item on the context menu of Java editor disappears for that project?

Is there a solution to that? A patch or upgrade? Or a kludge?

Further Info: Need to further assert that the context menu on project/package explorer is unaffected. The refactor item is still there.

It is the Java Editor that is affected - where the refactor item disappeared from the context menu.

Error Log:

Plug-in 'org.maven.ide.eclipse.refactoring' contributed an invalid Menu Extension (Path: 'org.eclipse.jdt.ui.refactoring.menu' is invalid): org.maven.ide.eclipse.editor.RenameProjectAction

An exception stack trace is not available.

Session data:
eclipse.buildId=2.3.3.201007151000-M2
java.version=1.6.0_18
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Framework arguments:  -product com.springsource.sts.ide
Command-line arguments:  -os linux -ws gtk -arch x86_64 -product com.springsource.sts.ide

error log of failed action when attempting to enable GWT:

Failed to update action com.google.gwt.eclipse.core.actions.AddResourcesToClientBundleAction

Exception trace:
ava.lang.ClassNotFoundException: com.google.gdt.eclipse.platform.jdt.model.PlatformJavaModelUtilities$IAnnotationNotAvailableException
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at com.google.gwt.eclipse.core.clientbundle.ClientBundleResource.isProbableClientBundleResource(ClientBundleResource.java:105)
at com.google.gwt.eclipse.core.clientbundle.ui.AddResourcesToClientBundleAction.selectionChanged(AddResourcesToClientBundleAction.java:203)
at org.eclipse.ui.internal.PluginAction.refreshEnablement(PluginAction.java:206)
at org.eclipse.ui.internal.PluginAction.selectionChanged(PluginAction.java:277)
at org.eclipse.ui.internal.ObjectActionContributor$1.run(ObjectActionContributor.java:157)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.ui.internal.ObjectActionContributor.contributeObjectActions(ObjectActionContributor.java:160)
at org.eclipse.ui.internal.ObjectActionContributorManager.contributeObjectActions(ObjectActionContributorManager.java:97)
at org.eclipse.ui.internal.PopupMenuExtender.addObjectActions(PopupMenuExtender.java:262)
at org.eclipse.ui.internal.PopupMenuExtender.menuAboutToShow(PopupMenuExtender.java:339)
at org.eclipse.jface.action.MenuManager.fireAboutToShow(MenuManager.java:338)
at org.eclipse.jface.action.MenuManager.handleAboutToShow(MenuManager.java:469)
at org.eclipse.jface.action.MenuManager.access$1(MenuManager.java:465)
at org.eclipse.jface.action.MenuManager$2.menuShown(MenuManager.java:491)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:241)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1282)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1263)
at org.eclipse.swt.widgets.Menu._setVisible(Menu.java:199)
at org.eclipse.swt.widgets.Display.runPopups(Display.java:3593)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3168)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
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:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
A: 

This is not what I'm experiencing. Below a screenshot showing the Refactoring entry in the contextual menu of a Maven Project:

alt text

And the Refactoring entry in the contextual menu of a Java Resource of this Maven Project (that I also get when right clicking in the Java editor):

alt text

But note that I'm not using Eclipse and m2eclipse like you are, I create Maven projects outside Eclipse and Import... > Existing Maven Projects (I'm not fan of wizards). Not sure this makes a difference though.

Pascal Thivent
A: 

I find it hard to swallow answering my own question, but ...

The answer is: To obtain a maven managed project in Eclipse, do not use m2eclipse menu to create or enable as Maven dependency managed project. Those m2eclipse menu items are are broken.

You have to use mvn archetype:generate commands at the shell/command window to create that project.

mvn archetype:generate \
 -DgroupId=holy.moly \
 -DartifactId=holymoly \
 -Dpackage=holy.moly \
 -Dversion=1.0-VOILA

And then in Eclipse use the import:maven:existing maven project menu item to import that project into Eclipse.

Some products give their respective advisory on how to generate a maven project from shell/command window, and then to be imported into Eclipse. For example, Vaadin's:

mvn archetype:generate \
-DarchetypeGroupId=com.vaadin \
-DarchetypeArtifactId=vaadin-archetype-clean \
-DarchetypeVersion=LATEST \
-DgroupId=holy.moly  \
-DartifactId=holymoly \
-Dversion=1.0 \
-Dpackaging=war

However, attempting to enable GWT would cause error.

Using IAM: I am editing to say that I uninstalled m2eclipse from one of my helios setup and installed IAM. IAM did not cause any menu items to disappear. I was able to enable GWT.

The refactor item was still on the menu but attempting to refactor on Java Editor or rename a file on Project explorer would fail:

java.lang.NullPointerException
    at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.run_aroundBody1$advice(RenameJavaElementAction.java:35)
    at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.run(RenameJavaElementAction.java:1)
    at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.doRun(RenameJavaElementAction.java:148)
    at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.run(RenameJavaElementAction.java:129)
    at org.eclipse.jdt.ui.actions.RenameAction.run(RenameAction.java:115)
    at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:278)
    at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:250)
    at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
    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:1258)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3552)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3171)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
    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:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
Blessed Geek