Menu

#11 Plugin doesn't work with Eclipse 4.6

9.x.x
closed
MarkusK
None
2016-09-15
2016-06-15
No

Starting Tomcat in Eclipse 4.6 doesn't work, neither with the new version 9.0.0 nor with the older 3.3.6.x I used before:

!ENTRY org.eclipse.ui 4 0 2016-06-14 16:24:07.896
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NullPointerException
        at net.sf.eclipse.tomcat.TomcatLauncherPlugin.log(TomcatLauncherPlugin.java:329)
        at net.sf.eclipse.tomcat.actions.StartActionDelegate.run(StartActionDelegate.java:41)
        at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:247)
        at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:228)
        at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:565)
        at org.eclipse.jface.action.ActionContributionItem.lambda$5(ActionContributionItem.java:436)
        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
        at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4410)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079)
        at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4228)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3816)
        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1121)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1022)
        at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:150)
        at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:687)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:604)
        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
        at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1519)

Reason:
The two log() methods in the TomcatLauncherPlugin class call org.eclipse.core.runtime.Plugin.getDescriptor() which is marked as deprecated and always returns null in Eclipse 4.6:

    /**
     * As the org.eclipse.core.runtime.compatibility plug-in has been removed in
     * Eclipse 4.6 this method is not supported anymore.
     *
     * <code>IPluginDescriptor</code> was refactored in Eclipse 3.0.
     *
     * The <code>getDescriptor()</code> method was only be called by plug-ins
     * which explicitly require the org.eclipse.core.runtime.compatibility
     * plug-in. It is not called anymore.
     *
     * @deprecated
     */
    @Deprecated
    public final IPluginDescriptor getDescriptor() {
        return null;
    }

Simple fix that WorksForMe(tm): Replace the two calls to getDescriptor() by toString():

diff --git a/net.sf.eclipse.tomcat/src/net/sf/eclipse/tomcat/TomcatLauncherPlugin.java b/net.sf.eclipse.tomcat/src/net/sf/eclipse/tomcat/TomcatLauncherPlugin.java
index f06688a..b9fffae 100644
--- a/net.sf.eclipse.tomcat/src/net/sf/eclipse/tomcat/TomcatLauncherPlugin.java
+++ b/net.sf.eclipse.tomcat/src/net/sf/eclipse/tomcat/TomcatLauncherPlugin.java
@@ -326,7 +326,7 @@

     static public void log(String msg) {
         ILog log = TomcatLauncherPlugin.getDefault().getLog();
-        Status status = new Status(IStatus.ERROR, TomcatLauncherPlugin.getDefault().getDescriptor().getUniqueIdentifier(), IStatus.ERROR, msg + "\n", null);
+        Status status = new Status(IStatus.ERROR, TomcatLauncherPlugin.getDefault().toString(), IStatus.ERROR, msg + "\n", null);
         log.log(status);
     }

@@ -336,7 +336,7 @@
         ex.printStackTrace(new PrintWriter(stringWriter));
         String msg = stringWriter.getBuffer().toString();

-        Status status = new Status(IStatus.ERROR, TomcatLauncherPlugin.getDefault().getDescriptor().getUniqueIdentifier(), IStatus.ERROR, msg, null);
+        Status status = new Status(IStatus.ERROR, TomcatLauncherPlugin.getDefault().toString(), IStatus.ERROR, msg, null);
         log.log(status);
     }

Discussion

  • MarkusK

    MarkusK - 2016-06-15
    • status: open --> closed
    • assigned_to: MarkusK
     
  • MarkusK

    MarkusK - 2016-06-15

    I adjusted your fix a little bit to use a constant containing the plugin id and just released version 9.0.1. Thank you for your contribution, Thorsten!

     

Log in to post a comment.