Hi all,
First of all sorry about the double posting I thought it might be
useful for both lists.
We’ve have a project that’s moving on quite quickly now using GWT for
display and Rails for the backend. Our application uses JSON for
communication, it works very well. The only problem we’ve had is debug
in hosted mode. Below is a solution that works for us, I hope that
other people might find it useful.
WARNING: before you run your application in debug, ensure that you
DON’T have the compile module in your public directory…
we remove it with a rake task just before we start up the hosted mode.
Forget and it will run, but debug ing will not work.
- Add the following to your config/routes.rb
repeat this for each GWT module
map.connect “my.gwt.test/*path”, :controller => “gwt_proxy”, :action
=> “proxy”
- create a controller called gwt_proxy and add the following code to it
!!! BIG FAT WARNING !!!
The below code works but isn’t nice.
require ‘net/http’
class GwtProxyController < ApplicationController
turn off the proxy
session :off
done authenticate the proxy requests
skip_before_filter :check_authentication
protect ourselfs from the loop that normal browswer get into
before_filter :reject_compile_js_requests
URL of gwt’s in built tomcat server
GWT_SERVER = “http://localhost:8888”
warning not a hosted mode broswer
NONE_HOSTED_MODE = “== WARNING PROXY REQUEST NOT HANDLED, YOU MUST
NOT USE A NORMAL BROSWER==”
GWT tomcat server not responding
PROXY_NOT_UP = “== GWT Server is not running at #{GWT_SERVER} ==”
this filter stops the recusive look that normal - no hosted mode
broswers get them selfs into.
def reject_compile_js_requests
if request.query_string.ends_with?(“compiled”)
puts NONE_HOSTED_MODE
render :text => NONE_HOSTED_MODE,:status => 500
return false
end
end
Proxy a request to gwt’s in built tomact server
TODO: we should really proxy status codes and headers…
def proxy
begin
req =
Net::HTTP.get_response(URI.parse("#{GWT_SERVER}/"+request.path))
text = req.body
render :text => text
rescue
puts PROXY_NOT_UP
render :text => PROXY_NOT_UP, :status => 500
end
end
end
- Start up your the gwt hosted mode browser with something like this,
notice the url at the end and the debug information.
java -XstartOnFirstThread -Xmx512M -Xdebug -
Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1035
-Dfile.encoding=MacRoman -classpath
com.google.gwt.dev.GWTShell
-style OBFUSCATED -logLevel DEBUG -whitelist ^http.*
http://localhost:3000/my.gwt.test/test.html
-
Start up your IDE and tell it to debug on the port shown in the
command above (1035) -
Enjoy debugging
David