开发者

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

开发者 https://www.devze.com 2022-12-27 02:35 出处:网络
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. T

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 an开发者_开发问答yone 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...


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消