Using RequestBuilder to communicate with a RESTful API on another port

114 views
Skip to first unread message

Alexander Orlov

unread,
May 31, 2011, 8:08:15 AM5/31/11
to Google Web Toolkit
I want to write a RESTful GWT frontend for a RESTful backend. The
problem is that the backend code (server) is written in Go and can't
run on the same port as GWT's dev server (port 8888 & 9997).

Due to XMLHttpRequest's (the underlying class behind RequestBuilder)
security restrictions I can't communicate with anything that isn't
running on the same port of the same host? Of course I can write GWT
frontend code, compile it and run it on the same host&port but this
dev approach isn't really feasible as I can't test anything while I'm
in dev mode.

So is there a way to make REST calls (via RequestBuilder or
XMLHttpRequest) to a server that isn't running on the same host&port?

-Alex

Thomas Broyer

unread,
May 31, 2011, 8:16:39 AM5/31/11
to google-we...@googlegroups.com
If you do not have server-side code in Java, then you can just start the DevMode in -noserver- mode and point it to your "Go" server, see http://code.google.com/webtoolkit/doc/latest/DevGuideCompilingAndDebugging.html#How_do_I_use_my_own_server_in_development_mode_instead_of_GWT's

Otherwise, you can deploy a "proxy servlet" in the embedded Jetty server, see http://code.google.com/p/google-web-toolkit/issues/detail?id=3131

Alexander Orlov

unread,
May 31, 2011, 8:21:10 AM5/31/11
to Google Web Toolkit
On May 31, 2:16 pm, Thomas Broyer <t.bro...@gmail.com> wrote:
> If you do not have server-side code in Java, then you can just start the
> DevMode in -noserver- mode and point it to your "Go" server, see http://code.google.com/webtoolkit/doc/latest/DevGuideCompilingAndDebu...

Yep, I guess that's what I need. Thx!

-Alex

Alexander Orlov

unread,
May 31, 2011, 11:32:14 AM5/31/11
to Google Web Toolkit
On May 31, 2:16 pm, Thomas Broyer <t.bro...@gmail.com> wrote:
> If you do not have server-side code in Java, then you can just start the
> DevMode in -noserver- mode and point it to your "Go" server, seehttp://code.google.com/webtoolkit/doc/latest/DevGuideCompilingAndDebu...

To accomplish this I use Maven's GWT plugin with the following config:

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.2.0</version>
<configuration>
<logLevel>INFO</logLevel>
<noServer>true</noServer>
<!-- .. -->
</plugin>

After "mvn gwt:run" I get the Dev Mode Console but after clicking on
"Launch Default Browser" the browser popups with
http://127.0.0.1:8888/commander/index.html?gwt.codesvr=127.0.0.1:9997


Calling the GWT container page manually leads to

"GWT module 'commander' may need to be (re)compiled"

...no matter whether I call the GWT container page via file:/// or http://

Executing the result of "mvn gwt:compile" works fine. But that's the
production code that takes minutes to compile.

Any tips how I can use the -noserver with Maven or IntelliJ (I don't
use Eclipse)?

Alexander Orlov

unread,
May 31, 2011, 12:02:54 PM5/31/11
to Google Web Toolkit
On May 31, 5:32 pm, Alexander Orlov <alexander.or...@loxal.net> wrote:
> Any tips how I can use the -noserver with Maven or IntelliJ (I don't
> use Eclipse)?

Ok, I've got it :)

The "?gwt.codesvr=127.0.0.1:9997" parameter was missing. So basically
my Go server plays Jetty.

Thomas Broyer

unread,
May 31, 2011, 12:26:21 PM5/31/11
to google-we...@googlegroups.com
Er, no. Without the gwt.codesvr, you run the "compiled JS" (or if you didn't "mvn gwt:compile", you run the almost-empty *.nocache.js generated by DevMode so you can use it (the DevMode)), with gwt.codesvr your trigger the DevMode browser plugin which connects back to the DevMode app (listening at 127.0.0.1:9997).
There's absolutely no Jetty involved here.
Reply all
Reply to author
Forward
0 new messages