Revision: 8421
Author: amitman...@google.com
Date: Tue Jul 27 17:24:40 2010
Log: Rollback update to Jetty7 since it is causing classloader problems in
conjunction with Spring.  Will update to Jetty 7.1.6 after fixing these
problems.

Patch by: jat
Review by: amitmanjhi

http://code.google.com/p/google-web-toolkit/source/detail?r=8421

Added:
 /trunk/dev/core/src/com/google/gwt/dev/shell/jetty/JettyNullLogger.java
Modified:
 /trunk/dev/build.xml
 /trunk/dev/core/src/com/google/gwt/dev/shell/jetty/JettyLauncher.java
 /trunk/eclipse/dev/.classpath
 /trunk/eclipse/user/.classpath
 /trunk/user/src/com/google/gwt/junit/JUnitShell.java

=======================================
--- /dev/null
+++ /trunk/dev/core/src/com/google/gwt/dev/shell/jetty/JettyNullLogger.java Tue Jul 27 17:24:40 2010
@@ -0,0 +1,50 @@
+/*
+ * 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) {
+  }
+}
=======================================
--- /trunk/dev/build.xml        Mon Jun 28 08:45:45 2010
+++ /trunk/dev/build.xml        Tue Jul 27 17:24:40 2010
@@ -55,7 +55,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-7.0.2.v20100331/jetty-7.0.2.v20100331.jar" />
+          <include name="jetty/jetty-6.1.11.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" />
@@ -112,8 +112,7 @@
<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-7.0.2.v20100331/jetty-7.0.2.v20100331.jar"
-            />
+          <zipfileset src="${gwt.tools.lib}/jetty/jetty-6.1.11.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" />
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/shell/jetty/JettyLauncher.java Thu Jun 24 08:11:49 2010 +++ /trunk/dev/core/src/com/google/gwt/dev/shell/jetty/JettyLauncher.java Tue Jul 27 17:24:40 2010
@@ -21,25 +21,24 @@
 import com.google.gwt.core.ext.UnableToCompleteException;
 import com.google.gwt.dev.util.InstalledHelpInfo;

-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 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 java.io.File;
 import java.io.IOException;
 import java.net.URL;
+import java.util.Iterator;

 /**
  * A {...@link ServletContainerLauncher} for an embedded Jetty server.
@@ -64,6 +63,7 @@
     /**
      * Log an HTTP request/response to TreeLogger.
      */
+    @SuppressWarnings("unchecked")
     public void log(Request request, Response response) {
       int status = response.getStatus();
       if (status < 0) {
@@ -110,23 +110,25 @@
             + " - " + request.getMethod() + ' ' + request.getUri() + " ("
             + userString + request.getRemoteHost() + ')' + bytesString);
         if (branch.isLoggable(logHeaders)) {
-          HttpConnection connection = request.getConnection();
-          logHeaders(branch.branch(logHeaders, "Request headers"),
-              logHeaders, connection.getRequestFields());
-          logHeaders(branch.branch(logHeaders, "Response headers"),
-              logHeaders, connection.getResponseFields());
+          // 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());
+          }
         }
       }
     }
-
-    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());
-      }
-    }
   }

   /**
@@ -146,10 +148,6 @@
       }
       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));
@@ -162,18 +160,9 @@
     public Logger getLogger(String name) {
       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) {
-      String formattedMsg = format(msg, arg0, arg1);
-      logger.log(TreeLogger.TRACE, formattedMsg);
+      logger.log(TreeLogger.TRACE, format(msg, arg0, arg1));
     }

     public boolean isDebugEnabled() {
@@ -183,10 +172,6 @@
     public void setDebugEnabled(boolean enabled) {
       // 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));
@@ -313,7 +298,7 @@

         // For a system path, load from the outside world.
         URL found;
-        if (WebAppContextWithReload.this.isSystemClass(checkName)) {
+        if (isSystemPath(checkName)) {
           found = systemClassLoader.getResource(name);
           if (found != null) {
             return found;
@@ -342,10 +327,23 @@
         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 (isSystemClass(name)) {
+        if (isSystemPath(name)) {
           try {
             return systemClassLoader.loadClass(name);
           } catch (ClassNotFoundException e) {
@@ -356,7 +354,7 @@
           return super.findClass(name);
         } catch (ClassNotFoundException e) {
           // Don't allow server classes to be loaded from the outside.
-          if (isServerClass(name)) {
+          if (isServerPath(name)) {
             throw e;
           }
         }
@@ -429,6 +427,7 @@
      */
private final ClassLoader systemClassLoader = Thread.currentThread().getContextClassLoader();

+    @SuppressWarnings("unchecked")
     private WebAppContextWithReload(TreeLogger logger, String webApp,
         String contextPath) {
       super(webApp, contextPath);
@@ -436,24 +435,12 @@

       // Prevent file locking on Windows; pick up file changes.
       getInitParams().put(
-          "org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false");
+          "org.mortbay.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());
@@ -474,12 +461,14 @@
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");
@@ -526,7 +515,7 @@
     Log.setLog(new JettyTreeLogger(branch));

     // Turn off XML validation.
- System.setProperty("org.eclipse.jetty.xml.XmlParser.Validating", "false");
+    System.setProperty("org.mortbay.xml.XmlParser.Validating", "false");

     AbstractConnector connector = getConnector();
     if (bindAddress != null) {
=======================================
--- /trunk/eclipse/dev/.classpath       Thu Jun 24 08:11:49 2010
+++ /trunk/eclipse/dev/.classpath       Tue Jul 27 17:24:40 2010
@@ -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-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/jetty/jetty-6.1.11.jar" sourcepath="/GWT_TOOLS/lib/jetty/jetty-6.1.11-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"/>
=======================================
--- /trunk/eclipse/user/.classpath      Mon Jun 28 08:45:45 2010
+++ /trunk/eclipse/user/.classpath      Tue Jul 27 17:24:40 2010
@@ -32,8 +32,8 @@
        <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-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/redist/json/r2_20080312/json-1.5.jar" sourcepath="/GWT_TOOLS/redist/json/r2_20080312/json-src.jar"/> <classpathentry kind="var" path="GWT_TOOLS/lib/javax/validation/validation-api-1.0.0.GA.jar" sourcepath="/GWT_TOOLS/lib/javax/validation/validation-api-1.0.0.GA-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="output" path="bin"/>
 </classpath>
=======================================
--- /trunk/user/src/com/google/gwt/junit/JUnitShell.java Fri Jun 25 08:29:28 2010 +++ /trunk/user/src/com/google/gwt/junit/JUnitShell.java Tue Jul 27 17:24:40 2010
@@ -58,9 +58,8 @@
 import junit.framework.TestCase;
 import junit.framework.TestResult;

-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.servlet.ServletHolder;
-import org.eclipse.jetty.webapp.WebAppContext;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.webapp.WebAppContext;

 import java.io.File;
 import java.lang.reflect.Constructor;
@@ -539,7 +538,7 @@
         {
           // Prevent file locking on Windows; pick up file changes.
           getInitParams().put(
-              "org.eclipse.jetty.servlet.Default.useFileMappedBuffer", 
"false");
+              "org.mortbay.jetty.servlet.Default.useFileMappedBuffer", 
"false");

           // Prefer the parent class loader so that JUnit works.
           setParentLoaderPriority(true);
@@ -881,8 +880,8 @@
   private int tries;

   /**
- * Enforce the singleton pattern. The call to GWTShell's ctor forces server
-   * mode and disables processing extra arguments as URLs to be shown.
+ * Enforce the singleton pattern. The call to {...@link GWTShell}'s ctor forces + * server mode and disables processing extra arguments as URLs to be shown.
    */
   private JUnitShell() {
     setRunTomcat(true);
@@ -1082,14 +1081,15 @@
       String servletClass = module.findServletForPath(path);
       path = '/' + module.getName() + path;
       if (!servletClass.equals(loadedServletsByPath.get(path))) {
-        ServletHolder holder = wac.addServlet(servletClass, path);
-        if (holder.isAvailable()) {
+        try {
+          Class<?> clazz = wac.loadClass(servletClass);
+          wac.addServlet(clazz, path);
           loadedServletsByPath.put(path, servletClass);
-        } else {
+        } catch (ClassNotFoundException e) {
           getTopLogger().log(
               TreeLogger.WARN,
               "Failed to load servlet class '" + servletClass
-                  + "' declared in '" + module.getName() + "'");
+                  + "' declared in '" + module.getName() + "'", e);
         }
       }
     }

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to