Update to Jetty 7.0.2.

Public review at: http://gwt-code-reviews.appspot.com/306803/show

Patch by: jat
Review by: scottb


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@8311 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/build.xml b/dev/build.xml
index cfc3b0c..1e3d0e8 100755
--- a/dev/build.xml
+++ b/dev/build.xml
@@ -53,7 +53,7 @@
           <include name="apache/tapestry-util-text-4.0.2.jar" />
           <include name="apache/ant-1.6.5.jar" />
           <include name="eclipse/jdt-3.4.2.jar" />
-          <include name="jetty/jetty-6.1.11.jar" />
+          <include name="jetty/jetty-7.0.2.v20100331/jetty-7.0.2.v20100331.jar" />
           <include name="icu4j/icu4j-4_4_1.jar" />
           <include name="protobuf/protobuf-2.2.0/protobuf-java-rebased-2.2.0.jar" />
           <include name="tomcat/ant-launcher-1.6.5.jar" />
@@ -110,7 +110,8 @@
           <zipfileset src="${gwt.tools.lib}/apache/tapestry-util-text-4.0.2.jar" />
           <zipfileset src="${gwt.tools.lib}/apache/ant-1.6.5.jar" />
           <zipfileset src="${gwt.tools.lib}/eclipse/jdt-3.4.2.jar" />
-          <zipfileset src="${gwt.tools.lib}/jetty/jetty-6.1.11.jar" />
+          <zipfileset src="${gwt.tools.lib}/jetty/jetty-7.0.2.v20100331/jetty-7.0.2.v20100331.jar"
+            />
           <zipfileset src="${gwt.tools.lib}/icu4j/icu4j-4_4_1.jar" />
           <zipfileset src="${gwt.tools.lib}/protobuf/protobuf-2.2.0/protobuf-java-rebased-2.2.0.jar" />
           <zipfileset src="${gwt.tools.lib}/tomcat/ant-launcher-1.6.5.jar" />
diff --git a/dev/core/src/com/google/gwt/dev/shell/jetty/JettyLauncher.java b/dev/core/src/com/google/gwt/dev/shell/jetty/JettyLauncher.java
index 3dedb92..6822506 100644
--- a/dev/core/src/com/google/gwt/dev/shell/jetty/JettyLauncher.java
+++ b/dev/core/src/com/google/gwt/dev/shell/jetty/JettyLauncher.java
@@ -21,24 +21,25 @@
 import com.google.gwt.core.ext.UnableToCompleteException;
 import com.google.gwt.dev.util.InstalledHelpInfo;
 
-import org.mortbay.component.AbstractLifeCycle;
-import org.mortbay.jetty.AbstractConnector;
-import org.mortbay.jetty.Request;
-import org.mortbay.jetty.RequestLog;
-import org.mortbay.jetty.Response;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.HttpFields.Field;
-import org.mortbay.jetty.handler.RequestLogHandler;
-import org.mortbay.jetty.nio.SelectChannelConnector;
-import org.mortbay.jetty.webapp.WebAppClassLoader;
-import org.mortbay.jetty.webapp.WebAppContext;
-import org.mortbay.log.Log;
-import org.mortbay.log.Logger;
+import org.eclipse.jetty.http.HttpFields;
+import org.eclipse.jetty.http.HttpFields.Field;
+import org.eclipse.jetty.server.AbstractConnector;
+import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.RequestLog;
+import org.eclipse.jetty.server.Response;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.RequestLogHandler;
+import org.eclipse.jetty.server.nio.SelectChannelConnector;
+import org.eclipse.jetty.util.component.AbstractLifeCycle;
+import org.eclipse.jetty.util.log.Log;
+import org.eclipse.jetty.util.log.Logger;
+import org.eclipse.jetty.webapp.WebAppClassLoader;
+import org.eclipse.jetty.webapp.WebAppContext;
 
 import java.io.File;
 import java.io.IOException;
 import java.net.URL;
-import java.util.Iterator;
 
 /**
  * A {@link ServletContainerLauncher} for an embedded Jetty server.
@@ -63,7 +64,6 @@
     /**
      * Log an HTTP request/response to TreeLogger.
      */
-    @SuppressWarnings("unchecked")
     public void log(Request request, Response response) {
       int status = response.getStatus();
       if (status < 0) {
@@ -110,25 +110,23 @@
             + " - " + request.getMethod() + ' ' + request.getUri() + " ("
             + userString + request.getRemoteHost() + ')' + bytesString);
         if (branch.isLoggable(logHeaders)) {
-          // Request headers
-          TreeLogger headers = branch.branch(logHeaders, "Request headers");
-          Iterator<Field> headerFields = request.getConnection().getRequestFields().getFields();
-          while (headerFields.hasNext()) {
-            Field headerField = headerFields.next();
-            headers.log(logHeaders, headerField.getName() + ": "
-                + headerField.getValue());
-          }
-          // Response headers
-          headers = branch.branch(logHeaders, "Response headers");
-          headerFields = response.getHttpFields().getFields();
-          while (headerFields.hasNext()) {
-            Field headerField = headerFields.next();
-            headers.log(logHeaders, headerField.getName() + ": "
-                + headerField.getValue());
-          }
+          HttpConnection connection = request.getConnection();
+          logHeaders(branch.branch(logHeaders, "Request headers"),
+              logHeaders, connection.getRequestFields());
+          logHeaders(branch.branch(logHeaders, "Response headers"),
+              logHeaders, connection.getResponseFields());
         }
       }
     }
+
+    private void logHeaders(TreeLogger logger, TreeLogger.Type logLevel,
+        HttpFields fields) {
+      int n = fields.size();
+      for (int i = 0; i < n; ++i) {
+        Field field = fields.getField(i);
+        logger.log(logLevel, field.getName() + ": " + field.getValue());
+      }
+    }
   }
 
   /**
@@ -149,6 +147,10 @@
       this.logger = logger;
     }
 
+    public void debug(String msg) {
+      logger.log(TreeLogger.SPAM, msg);
+    }
+
     public void debug(String msg, Object arg0, Object arg1) {
       logger.log(TreeLogger.SPAM, format(msg, arg0, arg1));
     }
@@ -161,8 +163,17 @@
       return this;
     }
 
+    public String getName() {
+      return "JettyTreeLogger";
+    }
+
+    public void info(String msg) {
+      logger.log(TreeLogger.TRACE, msg);
+    }
+
     public void info(String msg, Object arg0, Object arg1) {
-      logger.log(TreeLogger.TRACE, format(msg, arg0, arg1));
+      String formattedMsg = format(msg, arg0, arg1);
+      logger.log(TreeLogger.TRACE, formattedMsg);
     }
 
     public boolean isDebugEnabled() {
@@ -173,6 +184,10 @@
       // ignored
     }
 
+    public void warn(String msg) {
+      logger.log(TreeLogger.WARN, msg);
+    }
+
     public void warn(String msg, Object arg0, Object arg1) {
       logger.log(TreeLogger.WARN, format(msg, arg0, arg1));
     }
@@ -298,7 +313,7 @@
 
         // For a system path, load from the outside world.
         URL found;
-        if (isSystemPath(checkName)) {
+        if (WebAppContextWithReload.this.isSystemClass(checkName)) {
           found = systemClassLoader.getResource(name);
           if (found != null) {
             return found;
@@ -327,23 +342,10 @@
         return super.findResource(name);
       }
 
-      /**
-       * Override to additionally consider the most commonly available JSP and
-       * XML implementation as system resources. (In fact, Jasper is in gwt-dev
-       * via embedded Tomcat, so we always hit this case.)
-       */
-      @Override
-      public boolean isSystemPath(String name) {
-        name = name.replace('/', '.');
-        return super.isSystemPath(name)
-            || name.startsWith("org.apache.jasper.")
-            || name.startsWith("org.apache.xerces.");
-      }
-
       @Override
       protected Class<?> findClass(String name) throws ClassNotFoundException {
         // For system path, always prefer the outside world.
-        if (isSystemPath(name)) {
+        if (isSystemClass(name)) {
           try {
             return systemClassLoader.loadClass(name);
           } catch (ClassNotFoundException e) {
@@ -354,7 +356,7 @@
           return super.findClass(name);
         } catch (ClassNotFoundException e) {
           // Don't allow server classes to be loaded from the outside.
-          if (isServerPath(name)) {
+          if (isServerClass(name)) {
             throw e;
           }
         }
@@ -427,7 +429,6 @@
      */
     private final ClassLoader systemClassLoader = Thread.currentThread().getContextClassLoader();
 
-    @SuppressWarnings("unchecked")
     private WebAppContextWithReload(TreeLogger logger, String webApp,
         String contextPath) {
       super(webApp, contextPath);
@@ -435,12 +436,24 @@
 
       // Prevent file locking on Windows; pick up file changes.
       getInitParams().put(
-          "org.mortbay.jetty.servlet.Default.useFileMappedBuffer", "false");
+          "org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false");
 
       // Since the parent class loader is bootstrap-only, prefer it first.
       setParentLoaderPriority(true);
     }
 
+    /**
+     * Override to additionally consider the most commonly available JSP and
+     * XML implementation as system resources. (In fact, Jasper is in gwt-dev
+     * via embedded Tomcat, so we always hit this case.)
+     */
+    @Override
+    public boolean isSystemClass(String name) {
+      return super.isSystemClass(name)
+          || name.startsWith("org.apache.jasper.")
+          || name.startsWith("org.apache.xerces.");
+    }
+
     @Override
     protected void doStart() throws Exception {
       setClassLoader(new WebAppClassLoaderExtension());
@@ -461,14 +474,12 @@
   private static final String PROPERTY_NOWARN_WEBAPP_CLASSPATH = "gwt.nowarn.webapp.classpath";
 
   static {
-    // Suppress spammy Jetty log initialization.
-    System.setProperty("org.mortbay.log.class", JettyNullLogger.class.getName());
-    Log.getLog();
-
     /*
      * Make JDT the default Ant compiler so that JSP compilation just works
      * out-of-the-box. If we don't set this, it's very, very difficult to make
      * JSP compilation work.
+     *
+     * TODO(scottb): verify this is still needed
      */
     String antJavaC = System.getProperty("build.compiler",
         "org.eclipse.jdt.core.JDTCompilerAdapter");
@@ -515,7 +526,7 @@
     Log.setLog(new JettyTreeLogger(branch));
 
     // Turn off XML validation.
-    System.setProperty("org.mortbay.xml.XmlParser.Validating", "false");
+    System.setProperty("org.eclipse.jetty.xml.XmlParser.Validating", "false");
 
     AbstractConnector connector = getConnector();
     if (bindAddress != null) {
diff --git a/dev/core/src/com/google/gwt/dev/shell/jetty/JettyNullLogger.java b/dev/core/src/com/google/gwt/dev/shell/jetty/JettyNullLogger.java
deleted file mode 100644
index 81418ad..0000000
--- a/dev/core/src/com/google/gwt/dev/shell/jetty/JettyNullLogger.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2009 Google Inc.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.shell.jetty;
-
-import org.mortbay.log.Logger;
-
-/**
- * A Jetty {@link Logger} that suppresses all output.
- */
-public class JettyNullLogger implements Logger {
-
-  public void debug(String msg, Throwable th) {
-  }
-
-  public void debug(String msg, Object arg0, Object arg1) {
-  }
-
-  public Logger getLogger(String name) {
-    return this;
-  }
-
-  public void info(String msg, Object arg0, Object arg1) {
-  }
-
-  public boolean isDebugEnabled() {
-    return false;
-  }
-
-  public void setDebugEnabled(boolean enabled) {
-  }
-
-  public void warn(String msg, Throwable th) {
-  }
-
-  public void warn(String msg, Object arg0, Object arg1) {
-  }
-}
diff --git a/eclipse/dev/.classpath b/eclipse/dev/.classpath
index 03fbe25..b275f59 100644
--- a/eclipse/dev/.classpath
+++ b/eclipse/dev/.classpath
@@ -7,7 +7,7 @@
 	<classpathentry kind="var" path="GWT_TOOLS/lib/apache/ant-1.6.5.jar" sourcepath="/GWT_TOOLS/lib/apache/ant-1.6.5-src.zip"/>
 	<classpathentry kind="var" path="GWT_TOOLS/lib/apache/tapestry-util-text-4.0.2.jar" sourcepath="/GWT_TOOLS/lib/apache/tapestry-util-text-4.0.2-src.zip"/>
 	<classpathentry kind="var" path="GWT_TOOLS/lib/eclipse/jdt-3.4.2.jar" sourcepath="/GWT_TOOLS/lib/eclipse/jdt-3.4.2-src.zip"/>
-	<classpathentry kind="var" path="GWT_TOOLS/lib/jetty/jetty-6.1.11.jar" sourcepath="/GWT_TOOLS/lib/jetty/jetty-6.1.11-src.zip"/>
+	<classpathentry kind="var" path="GWT_TOOLS/lib/jetty/jetty-7.0.2.v20100331/jetty-7.0.2.v20100331.jar" sourcepath="GWT_TOOLS/lib/jetty/jetty-7.0.2.v20100331/jetty-7.0.2.v20100331-src.zip"/>
 	<classpathentry kind="var" path="GWT_TOOLS/lib/junit/junit-3.8.1.jar" sourcepath="/GWT_TOOLS/lib/junit/junit-3.8.1-src.zip"/>
 	<classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/ant-launcher-1.6.5.jar"/>
 	<classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/catalina-1.0.jar"/>
@@ -37,8 +37,8 @@
 	<classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/tomcat-jk2-2.1.jar"/>
 	<classpathentry kind="var" path="GWT_TOOLS/lib/tomcat/tomcat-util-5.1.jar"/>
 	<classpathentry kind="var" path="GWT_TOOLS/lib/sun/swingworker/swing-worker-1.1.jar"/>
-        <classpathentry kind="var" path="GWT_TOOLS/lib/htmlunit/htmlunit-r5607/htmlunit-core-js-r5607.jar" sourcepath="/GWT_TOOLS/lib/htmlunit/htmlunit-r5607/htmlunit-core-js-r5607-sources.jar"/>
-        <classpathentry kind="var" path="GWT_TOOLS/lib/htmlunit/htmlunit-r5607/htmlunit-r5607.jar" sourcepath="/GWT_TOOLS/lib/htmlunit/htmlunit-r5607/htmlunit-r5607-sources.jar"/>
+	<classpathentry kind="var" path="GWT_TOOLS/lib/htmlunit/htmlunit-r5607/htmlunit-core-js-r5607.jar" sourcepath="/GWT_TOOLS/lib/htmlunit/htmlunit-r5607/htmlunit-core-js-r5607-sources.jar"/>
+	<classpathentry kind="var" path="GWT_TOOLS/lib/htmlunit/htmlunit-r5607/htmlunit-r5607.jar" sourcepath="/GWT_TOOLS/lib/htmlunit/htmlunit-r5607/htmlunit-r5607-sources.jar"/>
 	<classpathentry kind="var" path="GWT_TOOLS/lib/protobuf/protobuf-2.2.0/protobuf-java-rebased-2.2.0.jar"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
diff --git a/eclipse/user/.classpath b/eclipse/user/.classpath
index 88d98c8..e63b8f5 100644
--- a/eclipse/user/.classpath
+++ b/eclipse/user/.classpath
@@ -32,6 +32,6 @@
 	<classpathentry combineaccessrules="false" kind="src" path="/gwt-dev"/>
 	<classpathentry kind="var" path="GWT_TOOLS/lib/htmlunit/htmlunit-r5607/htmlunit-r5607.jar" sourcepath="/GWT_TOOLS/lib/htmlunit/htmlunit-r5607/htmlunit-r5607-sources.jar"/>
 	<classpathentry kind="var" path="GWT_TOOLS/lib/htmlunit/htmlunit-r5607/htmlunit-core-js-r5607.jar" sourcepath="/GWT_TOOLS/lib/htmlunit/htmlunit-r5607/htmlunit-core-js-r5607-sources.jar"/>
-	<classpathentry kind="var" path="GWT_TOOLS/lib/jetty/jetty-6.1.11.jar" sourcepath="/GWT_TOOLS/lib/jetty/jetty-6.1.11-src.zip"/>
+	<classpathentry kind="var" path="GWT_TOOLS/lib/jetty/jetty-7.0.2.v20100331/jetty-7.0.2.v20100331.jar" sourcepath="GWT_TOOLS/lib/jetty/jetty-7.0.2.v20100331/jetty-7.0.2.v20100331-src.zip"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
diff --git a/user/src/com/google/gwt/junit/JUnitShell.java b/user/src/com/google/gwt/junit/JUnitShell.java
index b632d42..ec48515 100644
--- a/user/src/com/google/gwt/junit/JUnitShell.java
+++ b/user/src/com/google/gwt/junit/JUnitShell.java
@@ -58,8 +58,9 @@
 import junit.framework.TestCase;
 import junit.framework.TestResult;
 
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.webapp.WebAppContext;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.servlet.ServletHolder;
+import org.eclipse.jetty.webapp.WebAppContext;
 
 import java.io.File;
 import java.lang.reflect.Constructor;
@@ -538,7 +539,7 @@
         {
           // Prevent file locking on Windows; pick up file changes.
           getInitParams().put(
-              "org.mortbay.jetty.servlet.Default.useFileMappedBuffer", "false");
+              "org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false");
 
           // Prefer the parent class loader so that JUnit works.
           setParentLoaderPriority(true);
@@ -880,8 +881,8 @@
   private int tries;
 
   /**
-   * Enforce the singleton pattern. The call to {@link GWTShell}'s ctor forces
-   * server mode and disables processing extra arguments as URLs to be shown.
+   * Enforce the singleton pattern. The call to GWTShell's ctor forces server
+   * mode and disables processing extra arguments as URLs to be shown.
    */
   private JUnitShell() {
     setRunTomcat(true);
@@ -1081,15 +1082,14 @@
       String servletClass = module.findServletForPath(path);
       path = '/' + module.getName() + path;
       if (!servletClass.equals(loadedServletsByPath.get(path))) {
-        try {
-          Class<?> clazz = wac.loadClass(servletClass);
-          wac.addServlet(clazz, path);
+        ServletHolder holder = wac.addServlet(servletClass, path);
+        if (holder.isAvailable()) {
           loadedServletsByPath.put(path, servletClass);
-        } catch (ClassNotFoundException e) {
+        } else {
           getTopLogger().log(
               TreeLogger.WARN,
               "Failed to load servlet class '" + servletClass
-                  + "' declared in '" + module.getName() + "'", e);
+                  + "' declared in '" + module.getName() + "'");
         }
       }
     }
diff --git a/user/test/com/google/gwt/user/BadServlets.gwt.xml b/user/test/com/google/gwt/user/BadServlets.gwt.xml
new file mode 100644
index 0000000..09eec83
--- /dev/null
+++ b/user/test/com/google/gwt/user/BadServlets.gwt.xml
@@ -0,0 +1,31 @@
+<!--                                                                        -->
+<!-- Copyright 2007 Google Inc.                                             -->
+<!-- Licensed under the Apache License, Version 2.0 (the "License"); you    -->
+<!-- may not use this file except in compliance with the License. You may   -->
+<!-- may obtain a copy of the License at                                    -->
+<!--                                                                        -->
+<!-- http://www.apache.org/licenses/LICENSE-2.0                             -->
+<!--                                                                        -->
+<!-- Unless required by applicable law or agreed to in writing, software    -->
+<!-- distributed under the License is distributed on an "AS IS" BASIS,      -->
+<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        -->
+<!-- implied. License for the specific language governing permissions and   -->
+<!-- limitations under the License.                                         -->
+
+<module>
+  <inherits name='com.google.gwt.user.User' />
+
+  <servlet path='/notfound' class='org.example.NotFound' />
+  <servlet path='/ctor'
+      class='com.google.gwt.user.server.BadServlets$CtorException' />
+  <servlet path='/intf'
+      class='com.google.gwt.user.server.BadServlets$Interface' />
+  <servlet path='/nodef'
+      class='com.google.gwt.user.server.BadServlets$NoDefaultCtor' />
+  <servlet path='/nothttp'
+      class='com.google.gwt.user.server.BadServlets$NotHttpServlet' />
+  <servlet path='/static'
+      class='com.google.gwt.user.server.BadServlets$StaticException' />
+  <servlet path='/ok'
+      class='com.google.gwt.user.server.BadServlets$Ok' />
+</module>
diff --git a/user/test/com/google/gwt/user/ServletsSuite.java b/user/test/com/google/gwt/user/ServletsSuite.java
new file mode 100644
index 0000000..d4ae48c
--- /dev/null
+++ b/user/test/com/google/gwt/user/ServletsSuite.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2010 Google Inc.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.user;
+
+import com.google.gwt.junit.tools.GWTTestSuite;
+import com.google.gwt.user.client.BadServletsTest;
+
+import junit.framework.Test;
+
+/**
+ * Servlet tests not belonging elsewhere.
+ */
+public class ServletsSuite {
+  public static Test suite() {
+    GWTTestSuite suite = new GWTTestSuite("ServletsSuite");
+    suite.addTestSuite(BadServletsTest.class);
+    return suite;
+  }
+}
diff --git a/user/test/com/google/gwt/user/client/BadServletsTest.java b/user/test/com/google/gwt/user/client/BadServletsTest.java
new file mode 100644
index 0000000..04f3df2
--- /dev/null
+++ b/user/test/com/google/gwt/user/client/BadServletsTest.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2010 Google Inc.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.user.client;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.http.client.Request;
+import com.google.gwt.http.client.RequestBuilder;
+import com.google.gwt.http.client.RequestCallback;
+import com.google.gwt.http.client.RequestException;
+import com.google.gwt.http.client.Response;
+import com.google.gwt.junit.client.GWTTestCase;
+
+/**
+ * Test that bad servlets don't generate exceptions that leak out.
+ */
+public class BadServletsTest extends GWTTestCase {
+
+  @Override
+  public String getModuleName() {
+    return "com.google.gwt.user.BadServlets";
+  }
+
+  /**
+   * Make sure the servlet with no problems is reachable.
+   * @throws RequestException 
+   */
+  public void testOk() throws RequestException {
+    String url = GWT.getModuleBaseURL() + "ok";
+    RequestBuilder req = new RequestBuilder(RequestBuilder.GET, url);
+    delayTestFinish(5000);
+    req.sendRequest(null, new RequestCallback() {
+      public void onError(Request request, Throwable exception) {
+        fail(exception.toString());
+      }
+
+      public void onResponseReceived(Request request, Response response) {
+        assertEquals(200, response.getStatusCode());
+        assertEquals("ok", response.getText());
+        finishTest();
+      }
+    });
+  }
+}
diff --git a/user/test/com/google/gwt/user/server/BadServlets.java b/user/test/com/google/gwt/user/server/BadServlets.java
new file mode 100644
index 0000000..becd947
--- /dev/null
+++ b/user/test/com/google/gwt/user/server/BadServlets.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2010 Google Inc.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.user.server;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Holds servlets which are bad in various ways, used by BadServletsTest, to
+ * make sure that JUnitShell keeps going after a bad servlet is specified.
+ */
+public class BadServlets {
+
+  /**
+   * Test an abstract servlet.
+   */
+  public static abstract class Abstract implements Servlet {
+  }
+
+  /**
+   * Test a servlet that throws an exception in its constructor.
+   */
+  public static class CtorException extends HttpServlet {
+    public CtorException() {
+      super();
+      throw new RuntimeException("ctor failed");
+    }
+  }
+
+  /**
+   * Test a servlet that is just an interface.
+   */
+  public interface Interface extends Servlet {
+  }
+
+  /**
+   * Test a servlet with no default constructor.
+   */
+  public static class NoDefaultCtor extends HttpServlet {
+    
+    public NoDefaultCtor(int bogus) {
+      super();
+    }
+  }
+
+  /**
+   * Test a servlet that is not an HttpServlet.
+   */
+  public static class NotHttpServlet implements Servlet {
+
+    public void destroy() {
+    }
+
+    public ServletConfig getServletConfig() {
+      return null;
+    }
+
+    public String getServletInfo() {
+      return null;
+    }
+
+    public void init(ServletConfig config) throws ServletException {
+    }
+
+    public void service(ServletRequest req, ServletResponse res)
+        throws ServletException, IOException {
+    }
+  }
+
+  /**
+   * Ok servlet, to make sure the test setup is correct.
+   */
+  public static class Ok extends HttpServlet {
+    @Override
+    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+        throws ServletException, IOException {
+      resp.setStatus(HttpServletResponse.SC_OK);
+      resp.setContentType("text/plain");
+      PrintWriter writer = resp.getWriter();
+      writer.print("ok");
+      writer.flush();
+    }
+  }
+
+  /**
+   * Test a servlet that throws an exception in its static initializer.
+   */
+  public static class StaticException extends HttpServlet {
+    static {
+      @SuppressWarnings("unused")
+      int divideByZero = 1 / 0;
+    }
+  }
+}