Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging a Google Web Toolkit application that has an error when deployed on Google App Engine

I have a Google Web Toolkit application that I am deploying to Google App Engine. In the deployed application, I am getting a JavaScript error Uncaught TypeError: Cannot read property 'f' of null. This sounds like the JavaScript equivalent of a Java NullPointerException.

The problem is that the GWT JavaScript is obfuscated, so it's impossible to debug in the browser and I can't reproduce the same problem in hosted mode where I could use the Java debugger. I think the reason I'm only seeing the error on the deployed application is that the database I'm using on the GAE server is triggering something differently than the test database I'm using during testing and development.

So, any ideas about the best way to proceed? I've thought of the following things:

  • Deploy a non-obsfucated version of my application. Despite a lot of Googling, I can't figure out how to do this using the automatic deploy script provided with the Google Eclipse Plugin. Does anyone know?
  • Download and copy my GAE data to the local server
  • Somehow point my development code to use the GAE server for data instead of the local test database. This seems like the best idea...

Can anyone suggest how to proceed here?

Finally, is there a way to catch these JavaScript errors on the production server and log them somewhere? Without logging, I won't have anyway to know if my users are having errors that don't occur on the server. The GWT.log() function is automatically stripped out of the production code...

like image 793
gerdemb Avatar asked Apr 14 '10 19:04

gerdemb


People also ask

Which is a command to deploy the application in the Google App Engine?

App Engine provides the gcloud app deploy command, which builds an image with your source code and deploys that image on App Engine. You can use the cloud-sdk image as a build step in your config file to invoke gcloud commands within the image.

Is in Google App Engine application run in secure sandbox environment?

In the standard environment, your application runs on a lightweight instance inside of a sandbox. This sandbox restricts what your application can do. For example, the sandbox only allows your app to use a limited set of binary libraries, and your app cannot write to disk.

What is SDK in Google App Engine?

Google Cloud SDK: Tools for all languages. Google Cloud CLI lets you manage resources and services from the command line. It also contains service and data emulators to speed up local development. Cloud Shell lets you code or use a terminal directly in the web-browser.


1 Answers

1) If you can replicate the needed state of your GAE database locally, then run the javascript compiled version on your local machine. This will almost certainly give the same error, but is a lot less expensive than a full AppEngine deployment. Do this by compiling your app with the GWT compiler, then start it normally, then point your browser to the specified address without the ?gwt.codesvr=127.0.0.1:9997 part.

2) Use the -style PRETTY or -style DETAILED with the GWT compiler to get nicer javascript. If you compile locally with this flag once, then deploying to AppEngine (with the Eclipse plugin) will send the same non-obfuscated version.

3) Instrument your code (Window.alert() works fine) to figure out exactly where the error happens. This is especially useful to find where the javascript execution deviates from the hosted mode execution.

4) Speed-up your compilation process by keeping only one permutation. See how to do this there: How do I speed up the gwt compiler?

5) Javascript errors that don't show up in the development version or in unit tests are (almost always) due to a bug in GWT, after you've investigated a little, drop by the GWT forum or issue tracker and see if it's a known bug and whether or not there is a workaround.

like image 181
Philippe Beaudoin Avatar answered Oct 03 '22 01:10

Philippe Beaudoin