PaperCut Blog

Inside PaperCutWayback

Gotta love open source … I fixed it myself

I’m currently using the excellent Eclipse Java IDE for development work, and using the Jetty Launcher plugin to enable firing up the Jetty web server within Eclipse. It allows you to debug your web application directly in the IDE, making Java web development much smoother.

Unfortunately the current version of the Jetty Launcher does not work with the latest Jetty release (5.1), and Jetty 5.0 doesn’t seem to be available for download anymore. I searched the issue database at SourceForge and found that the issue had been reported by Marino Jonsson, and he suggested a possible fix. But there was no response from the project owner. The plugin is open source, so I figured I should get the source, code up the fix and build the project for myself.

I haven’t done any Eclipse Plugin development, so it took some fiddling with the Ant build.xml to get the plugin to build (the Eclipse jars could not be found when compiling). The result is a jettylauncher.jar that you can drop into your Jetty Launcher 1.2.1 directory and overwrite the old one (in [eclipsedir]/plugins/com.iw.plugins.jettylauncher_1.2.1).

Download the fixed Jetty Launcher (jettylauncher.jar)

If you’re interested in what I changed, here’s the unified diff …

diff -u -r1.9
---	29 Aug 2004 16:42:37 -0000	1.9
+++	17 Feb 2005 12:21:53 -0000
@@ -29,6 +29,8 @@
import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
@@ -303,7 +305,8 @@
public static String getJettyVersionString(File jarLocFile)
throws MalformedURLException, ClassNotFoundException,
-		InstantiationException, IllegalAccessException, NoSuchFieldException
+		InstantiationException, IllegalAccessException, NoSuchFieldException,
+        NoSuchMethodException, InvocationTargetException
ClassLoader currentClassLoader = null;
currentClassLoader = Thread.currentThread().getContextClassLoader();
@@ -314,10 +317,20 @@
URLClassLoader jarClassLoader = URLClassLoader.newInstance(
new URL[]{jarLocFile.toURL()}, currentClassLoader);
Class versionClass = jarClassLoader.loadClass("org.mortbay.http.Version");
-		Object version = versionClass.newInstance();
-		Field versionImplField = versionClass.getField("__VersionImpl");
-		String versionString = (String)versionImplField.get(version);
-		return versionString;
+        String versionString;
+        try {
+    		Object version = versionClass.newInstance();
+    		Field versionImplField = versionClass.getField("__VersionImpl");
+    		versionString = (String)versionImplField.get(version);
+        } catch (NoSuchFieldException e) {
+            // This must be Jetty 5.1+
+            Method method = versionClass.getMethod("getImplVersion", null);
+            versionString = (String) method.invoke(null, null);
+        }
+        return versionString;



  • Elifarley

    Well, just wanted to say thanks for your fixed jar !

  • Elifarley

    Just tried to open the preference page for your modified Jetty Launcher, but then I got this error:

    Plug-in com.iw.plugins.jettylauncher was unable to load class com.iw.plugins.jetty.launcher.JettyLaunchTabGroup.

    java.lang.ClassNotFoundException: com.iw.plugins.jetty.launcher.JettyLaunchTabGroup
    at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(
    at org.eclipse.osgi.framework.adaptor.core.AbstractClassLoader.loadClass(
    at java.lang.ClassLoader.loadClass(
    at org.eclipse.osgi.framework.internal.core.BundleLoader.loadClass(
    at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(
    at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(
    at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(
    at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(
    at org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationTabGroupExtension.newTabGroup(
    at org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationPresentationManager.getTabGroup(
    at org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationTabGroupViewer$
    at org.eclipse.swt.custom.BusyIndicator.showWhile(
    at org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationTabGroupViewer.createGroup(
    at org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationTabGroupViewer.showInstanceTabsFor(
    at org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationTabGroupViewer.displayInstanceTabs(
    at org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationTabGroupViewer$
    at org.eclipse.swt.custom.BusyIndicator.showWhile(
    at org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationTabGroupViewer.inputChanged(
    at org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationTabGroupViewer.setInput(
    at org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDialog.handleLaunchConfigurationSelectionChanged(
    at org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDialog$2.selectionChanged(
    at org.eclipse.jface.viewers.Viewer$
    at org.eclipse.jface.viewers.Viewer.fireSelectionChanged(
    at org.eclipse.jface.viewers.StructuredViewer.updateSelection(
    at org.eclipse.jface.viewers.StructuredViewer.handleSelect(
    at org.eclipse.jface.viewers.StructuredViewer$4.widgetSelected(
    at org.eclipse.jface.util.OpenStrategy.fireSelectionEvent(
    at org.eclipse.jface.util.OpenStrategy.access$400(
    at org.eclipse.jface.util.OpenStrategy$1.handleEvent(
    at org.eclipse.swt.widgets.EventTable.sendEvent(
    at org.eclipse.swt.widgets.Widget.sendEvent(
    at org.eclipse.swt.widgets.Display.runDeferredEvents(
    at org.eclipse.swt.widgets.Display.readAndDispatch(
    at org.eclipse.jface.window.Window.runEventLoop(
    at org.eclipse.debug.ui.DebugUITools$
    at org.eclipse.swt.custom.BusyIndicator.showWhile(
    at org.eclipse.debug.ui.DebugUITools.openLaunchConfigurationDialogOnGroup(
    at org.eclipse.debug.ui.DebugUITools.openLaunchConfigurationDialogOnGroup(
    at org.eclipse.ui.internal.PluginAction.runWithEvent(
    at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(
    at org.eclipse.jface.action.ActionContributionItem.access$500(
    at org.eclipse.jface.action.ActionContributionItem$7.handleEvent(
    at org.eclipse.swt.widgets.EventTable.sendEvent(
    at org.eclipse.swt.widgets.Widget.sendEvent(
    at org.eclipse.swt.widgets.Display.runDeferredEvents(
    at org.eclipse.swt.widgets.Display.readAndDispatch(
    at org.eclipse.ui.internal.Workbench.runEventLoop(
    at org.eclipse.ui.internal.Workbench.runUI(
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(
    at org.eclipse.core.internal.runtime.PlatformActivator$
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at org.eclipse.core.launcher.Main.basicRun(
    at org.eclipse.core.launcher.Main.main(

    java.vendor=Sun Microsystems Inc.
    BootLoader constants: OS=freebsd, ARCH=x86, WS=gtk, NL=en

  • Matt Doran

    That’s wierd. It works for me. Looks like it can’t even find the plugin classes. Did you drop the new version of the plugin into the /plugins/.. directory? If you drop the old one back in, does it work again?

  • Elifarley

    First, I copied your jar over the old one and got the error above.
    Now, I copied the original jar over your jar and got the old error (‘/blah/blah/blahblah/jetty-5.1.2 is not a valid Jetty installation directory’).

    In case I manage to fix it, I’ll let you know.

  • Matt Doran

    Hmmmm… I’m using Eclipse 3.0.1 (on Windows). Are you using a different version?

  • Elifarley

    I’m using Eclipse 3.0.1 too, on FreeBSD 5.3

  • Wayland Chan

    This patch isn’t working for me when using Eclipse 3.1M4 and Jetty 5.1.2

    Same error about “not a valid Jetty installation directory”.

  • Mark Stang

    Does anyone have a fix for this on a non-windows platform?



  • Hi, this is the current maintainer of jettylauncher. Sorry guys! I totally missed the bugreports. I am used to getting email notices whenever new issues are reported, but that didn’t happen this time. Furthermore I have been very bussy with another project (Wicket), so I did not check the jettylauncher site for a while.

    Anyway, there is a new build now, available at both the SF download site and the eclipse update site ( The new build supports Jetty 5.1.x now, and – as you suggested – I put in another catch so that jettylauncher won’t fail when it does not regconize the version of Jetty. Furthermore, it supports Eclipse 3.1 M6 (M6 broke some stuff) while still supporting 3.0.x (the patch that was submitted as part of the bugreport for M6 only supports 3.1).

    If you have any problems with the new build, pls send a note to the email list, or to me directly.


    Eelco Hillenius