Developing with GWT (in eclipse) when NOT using a Java Backend

648 Views Asked by At

I want to use a python backend while developing a SmartGWT front end. In order to get the debugging working correctly, I think I need the dev server running in eclipse which means the webserver will be running in eclipse.

My python (Django) backend needs to serve the requests for the data and I'd like it to not be a cross-domain issue, however cross-domain also seems to require the ports match too.

What is the simplest way to work around this? Been thinking about setting up my hosts file with a bogus domain and then have two entries, one for data, one for js. But, this requires setting up a second IP on the machine because the ports have to match too. If I want anyone else to be able to see the pages I can't use localhost and my external IP since they won't be able to get to my localhost.

Is there some simpler setup? Is there some simple proxy piece I could drop into the eclipse dev server that would proxy the data requests to a different server? Other ideas?

3

There are 3 best solutions below

0
On

The easiest way to do it is if you have both backend and frontend on your development machine.
For my projects I am using GWT on the frontend and cherrypy (python) on the backend.

I set up both projects in eclipse and when developing I start a debugger for the cherrypy backend and one for the GWT frontend. So I can basically debug backend and frontend at the same time. Works really good. Communication between python backend and gwt frontend is done via RequestBuilder (JSON) and the good thing about this setup is that I can test the backend's data communication directly without GWT.

So the development url is usually something like: http://localhost:8080/?gwt.codesvr=127.0.0.1:9997

Port 8080 is used by my cherrypy backend.

0
On

I am using a proxy servlet in my gwt setup for this purpose.

I am using a tomcat proxy servlet from jetty util artifact:

<dependency>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>jetty-util</artifactId>
    <version>6.1.22</version>
    <scope>runtime</scope>
</dependency>

My web.xml looks like this:

<servlet>
    <servlet-name>JettyProxy</servlet-name>
    <servlet-class>org.mortbay.servlet.ProxyServlet$Transparent</servlet-class>
    <init-param>

        <param-name>ProxyTo</param-name>
        <param-value>http://yourserver</param-value>
    </init-param>
    <init-param>

        <param-name>Prefix</param-name>
            <!-- will be removed from request -->
        <param-value>/prefix/</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>JettyProxy</servlet-name>
        <url-pattern>/prefix/*</url-pattern>
    </servlet-mapping>

If you get some weired error about some _context variable, make sure that the jetty-util.jar is in your classpath before the GWT SDK.

0
On