3
votes

I'm developing a GWT app that will be deployed to GAE. I have installed the Google-Eclipse plugin which also pulled down the GWT and GAE SDKs. But now that I am sitting down and actually thinking about things, I've become very confused as to how to both debug and run apps locally on my machine.

Normally, when I have a Java web app (I deploy to Tomcat; I'm just familiar with it), my options are as follows:

  • Create a remote Debug Configuration for my app, deploy the WAR to my local Tomcat container, but in such a way that I can debug it (set breakpoints, step through server-side code) right from inside Eclipse
  • Just deploy it to the Tomcat container, fire up a browser at http://localhost:8080/MyApp and start using/manually-testing the app locally

I want to accomplish the same, but with GWT and GAE there are so many options for both, and they become exponentially more confusing (to a newcomer such as myself) when you pair them together on the same machine:

Ultimately, I'd like to be able to do the following:

  • Debug the server app, including setting breakpoints, stepping through code, etc., right from inside Eclipse
  • Debug the client app, including setting breakpoints, stepping through code, etc., from inside a browser plugin like Firebug or Chrome Developer Tools, locally on my machine
  • Debug the app (both client- and server-side code in tandem), including setting breakpoints, stepping through code, etc., right from inside Eclipse
  • Same as above (debug the entire app, client- and server-side), from inside Eclipse, but where the server is running on a different (remote) machine. This way I can debug my app as it is running on my QA machine/environment, right from inside the Eclipse instance on my development machine
  • Run the app locally and simulate production; that is, deploy the backend to my GAE app dev server, and then open up a browser and go to the correct URL for accessing my app as it is served up by the local GAE dev appserver

I think the root of my confusion stems from the fact that both GWT and GAE SDKs run in so-called "dev modes", and because they address different tiers (client and server) its tough to wrap my head around what setup/configs are necessary to be able to isolate them if needed, or test them in tandem if needed. Thanks in advance for any help here!

2
did my answer helped?quarks

2 Answers

6
votes

I'll try to answer your questions as best I can. I recently inherited a code base of GWT, and have used app engine, so I'll do my best.

First of all, your sever side code is run by GWT SDK in a Jetty Servlet container. Your client side code is compiled to javascript, and run in the browser. Therefore, you can run your client code against any servlet server backend really easily. So when you are running GAE in 'dev mode' you have compiled your java, and are running a servlet with a GWT entrypoint in the GAE dev servlet container.

Setting up a local environment is fairly easy. When in eclipse, you can right click on your project and do 'Run As' or 'Debug As'. In the 'Run Configurations' and 'Debug Configurations' option, you will see a Google icon in the list titled 'Web Application'. You should create a profile to remember the options.

This configuration gives you a few options. If you have the appropriate GAE files, you can go to the 'App Engine' tab and configure options for that there. Under the 'Sever' tab, you have two options. If you check the 'run built-in server' option. GWT will run your servlets in it's Jetty container, and run the GWT client code server. If not, it will only run the client code server which allows you to change client code on the fly, and debug client code in eclipse. Eclipse will give you a nifty URL such as the following.

http://127.0.0.1:8888/index.jsp?gwt.codesvr=127.0.0.1:9997

This is really two parts, and weather you are using the built in jetty servlet container or not, it will look the same.

The first part is the http://127.0.0.1:8888/index.jsp -This is your running servlet container, it can be running on tomcat, web-logic, or GWT dev server, or any servlet container.

The second part is the ?gwt.codesvr=127.0.0.1:9997 -This is some GWT magic that when used in conjunction with the browser GWT development plugin, will allow you to change client code at runtime, and debug your javascript as java in eclipse.

If I'm only doing client side code changes, I will sometimes replace the http://127.0.0.1:8888/index.jsp with our dev server url : http://mydevserver:1234/myapp/index.jsp?gwt.codesvr=127.0.0.1:9997 This allows me to run the client code server locally without running the server side code locally. Note that I can access the client code that was deployed to dev by accessing the dev servlet directly without the gwt.codesvr parameter.

I hope this helps. I may be able to elaborate on parts of this if you have questions.

0
votes

This Google Eclipse Plugin should get you running. It is basically a plugin for Eclipse that will help you create GWT + GAE application (with few clicks and type) then be able to run your app directly from Eclipse.