Urgent security message for all NG/MF customers

Choose your language

Choose your login

Contact us

Blog

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).

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

diff -u -r1.9 Utils.java — Utils.java 29 Aug 2004 16:42:37 -0000 1.9 +++ Utils.java 17 Feb 2005 12:21:53 -0000 @@ -29,6 +29,8 @@ import java.io.File; import java.io.IOException; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; @@ -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;
    ```\}
    

/**