Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jetty and GWT (Google Web Toolkit)

Tags:

gwt

jetty

As I understand it, GWT uses an embedded Jetty server. Can anyone please tell me where I can find the Jetty .xml configuration files used by GWT? I have a webapp which makes uses of Jetty's ContinuationFilter and ProxyServlet. The app works fine under GWT but fails when run in a separate Jetty instance outside of GWT. If I can replicate the GWT Jetty config then I think I'll be okay.

Edit for more info:

My webapp's web.xml reads as follows:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

  <filter>
    <filter-name>JettyContinuationFilter</filter-name>
    <filter-class>org.eclipse.jetty.continuation.ContinuationFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>JettyContinuationFilter</filter-name>
    <url-pattern>/bugzilla/*</url-pattern>
  </filter-mapping>

  <!-- Servlets -->
  <servlet>
    <servlet-name>greetServlet</servlet-name>
    <servlet-class>com.searchsystem.gwt.server.GreetingServiceImpl</servlet-class>
  </servlet>

    <servlet>
     <servlet-name>jetty-proxy-servlet</servlet-name>
     <servlet-class>org.eclipse.jetty.servlets.ProxyServlet$Transparent</servlet-class>
     <init-param>
        <param-name>ProxyTo</param-name>
        <param-value>http://localhost/</param-value>
     </init-param>
     <init-param>
       <param-name>Prefix</param-name>
       <param-value>/</param-value>
     </init-param>
     <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>greetServlet</servlet-name>
    <url-pattern>/dashboard/greet</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
     <servlet-name>jetty-proxy-servlet</servlet-name>
     <url-pattern>/bugzilla/*</url-pattern>
  </servlet-mapping> 

  <!-- Default page to serve -->
  <welcome-file-list>
    <welcome-file>Dashboard.html</welcome-file>
  </welcome-file-list>

</web-app>

and the link to my Bugzilla installation is in this form:

com.google.gwt.user.client.ui.Frame bugFrame = new Frame("/bugzilla/");

Running under Jetty 6.1.26, I get this output:

Request Attributes
Attribute:  Value:
javax.servlet.forward.request_uri   /bugzilla/
org.mortbay.jetty.error_page    /jspsnoop/ERROR/404
javax.servlet.forward.servlet_path  /bugzilla/
testFilter  1
javax.servlet.error.message     NOT_FOUND
requestInitialized  ''
javax.servlet.forward.context_path  
javax.servlet.error.status_code     404
javax.servlet.error.servlet_name    default
org.mortbay.jetty.newSessionId  47deq3eo5kblxfrvtc5rljrg
javax.servlet.error.request_uri     /bugzi

lla/

like image 219
Clive Avatar asked Mar 07 '11 14:03

Clive


2 Answers

there is no jetty.xml. GWT sets up the Server programmatically. You can find the setup in

com.google.gwt.dev.shell.jetty.JettyLauncher

contained in the gwt-dev.jar

like image 120
Holgzn Avatar answered Oct 05 '22 21:10

Holgzn


See: Serving a GWT Application with an Embedded Jetty Server by Brandon Tilley (code extract shown below). He seems to have achieved it quite seamlessly, a process which I will be confirming myself tomorrow.

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.webapp.WebAppContext;

public class EmbeddedGwt {

    public static void main(String[] args) throws Throwable {

        // Create an embedded Jetty server on port 8080
        Server server = new Server(8080);

        // Create a handler for processing our GWT app
        WebAppContext handler = new WebAppContext();
        handler.setContextPath("/");
        handler.setWar("./apps/GwtApplication.war");

        // If your app isn't packaged into a WAR, you can do this instead
        WebAppContext altHandler = new WebAppContext();
        altHandler.setResourceBase("./apps/GwtApplication");
        altHandler.setDescriptor("./apps/GwtApplication/WEB-INF/web.xml");
        altHandler.setContextPath("/");
        altHandler.setParentLoaderPriority(true);

        // Add it to the server
        server.setHandler(handler);

        // Other misc. options
        server.setThreadPool(new QueuedThreadPool(20));

        // And start it up
        server.start();
        server.join();
    }
}
like image 41
Keldon Alleyne Avatar answered Oct 05 '22 21:10

Keldon Alleyne