Search code examples
gwtjettygwt2

Deploy on different context on embedded Jetty in GWT hosted mode


While running my webapp using GWT hosted mode, I haven't found a way to deploy it outside root context of Jetty. I could only do that while using an independent app server and running hosted mode without Jetty.

Is there a way to run directly on embedded Jetty, but outside of root context?


Solution

  • I am not sure whether you checked up on google groups for this. This works for me https://groups.google.com/forum/?fromgroups=#!topic/google-web-toolkit/a8OsRmMSaMg

    Create file jetty-web.xml in yours WEB-INF directory

    <?xml version="1.0"  encoding="UTF-8"?> 
    <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" 
    "http://jetty.mortbay.org/configure.dtd"> 
    <Configure class="org.mortbay.jetty.webapp.WebAppContext"> 
    
            <Set name="contextPath">/myapp</Set> 
    
    </Configure> 
    

    Solution for GWT >= 2.6

    <?xml version="1.0"  encoding="UTF-8"?>
    <!DOCTYPE Configure PUBLIC 
        "-//Mort Bay Consulting//DTD Configure//EN" 
        "http://www.eclipse.org/jetty/configure_9_0.dtd">
    
    <Configure class="org.eclipse.jetty.webapp.WebAppContext">
        <Set name="contextPath">/contextpath</Set>
    </Configure>