Google Chrome makes GWT apps Zoom!

September 5, 2008

When I first heard about Google Chrome my reaction was “Huh?  Another browser to support?”  However, now that the browser has been released I’ve realized why they bothered.  It’s simply the fastest and best looking browser for Windows right now.  I love the look of it, but even more so I love the speed of it!

I am the developer and user of online accounting software for small businesses written using the Google Web Toolkit (GWT).  When I tried our software in Chrome out of curiousity I was astounded to see how fast it was – first, it loads regular web pages as fast or faster than Opera, my old favorite browser.  Second, it loads and runs my accounting application much faster than I’ve ever seen before!

I was quite intrigued by this so I went and actually read the comic Google released about Chrome to find out more.  Apparently they contracted a company to write a new javascript JIT engine to run javascript, which they’ve apparently done a great job of!  And, it’s open source.

Hopefully Safari, Firefox, Opera, and (if we’re really lucky) Internet Explorer will take advantage of their Javascript engine so we can all enjoy faster Web 2.0 DHTML applications.


GWT to lighttpd/apache to glassfish 502 proxy or 500 internal errors fix

August 22, 2008

I’ve been dealing with this for a while now trying to figure out why, when using my online accounting software, users sporadically get a StatusCodeException when sending requests to the server.  I finally this week figured out what was going on; glassfish was dropping the connection or sending bad responses occasionally because it doesn’t behave in the was that the mod_proxy modules of these webservers expect it to.

Originally I was running lighttpd and I was thinking this might be a bug in lighttpd, so I eventually switched to apache.  Once I was running apache I got a much more verbose error – instead of just a plan 500 or 502 status code I got a message.  I googled that error message plus glassfish and found the solution.

I thought I’d share it here so that future searchers who are using lighttpd or apache will have more places to find the answer.

To fix the issue, add:

SetEnv force-proxy-request-1.0 1

SetEnv proxy-nokeepalive 1

To your apache httpd.conf.  I don’t know what the equivalent fix for lighttpd is, if there is any.

From this fix, it appears that glassfish is misbehaving in some way in relation to being behind a proxy, but I don’t what way that is and I’m just glad I fixed this mysterious problem!

If any of you readers have more information about this issue, please comment!

GWT: Using source-path to create your own JRE emulation classes

August 15, 2008

I recently ran into an issue where a class I share between GWT and server-side java code would really, really benefit from being able to accept or return a Calendar object.  However, GWT doesn’t come with a Calendar class, so the appeared to be impossible.  Or, is it?

After some digging around in the documentation I discovered that GWT provides a directive in their module XML called “super-path”.  By adding something like:

<super-path path=”gwtonly”/>

To my *.gwt.xml file, I can tell GWT to load my own emulation classes when compiling javascript; when running in hosted mode, it will use the Java implementation of these classes.

Here’s an example source tree structure for this:

  • myapp/
  • myapp/MyApp.gwt.xml
  • myapp/client/*.java
  • myapp/gwtonly/java/lang/
  • myapp/gwtonly/java/lang/

In my Calendar and GregorianCalendar I just define exactly the methods and constants that I need for the code to *compile*.  Note that I’m not planning to actually use these classes;  I could, but the implementation is so minimal it would cause confusion for future programmers who wouldn’t understand why the calendar class behaved so weirdly in client-side code.

However, now I discovered that I have errors in my code when I compile.  Huh?  In eclipse it’s happy but in GWT it says something like “package declaration should be java.lang, but it should be”.  Oh, I see, it’s really using that package as a source folder, not as a package.  So, I fix it by changing the “package” declaration at the top to “java.lang”.  Guess who is unhappy now?  eclipse!  The two compilers can’t see eye-to-eye any more.

There is a solution – eclipse has a feature called “exclusion filters”.  I open the “Java Build Path” panel for the project, find the source folder that has all of this in it, and add an “exclude” filter for myapp/gwtonly/.  Now eclipse just ignores those files; I’ve lost a lot of eclipse java features as a result, but at least it works.

All this is part of my work on simple online accounting software, if you’re a consultant, entrepreneur, virtual assistant, bookkeeper, or freelancer go check it out.

Are Dynamic Languages More Powerful? I don’t think so

March 2, 2008

Let’s say that power means “the amount of work done per unit of time.”

It could be said that development is made up of these types of work (and much more):

  • Design
  • Prototyping
  • Learning the Language
  • Writing New Code
  • Understanding Old Code
  • Refactoring
  • Debugging New Code
  • Debugging Old Code
  • Reading Other People’s Code
  • Debugging Other People’s Code
  • Making Use of Libraries
  • Making Libraries
  • Refactoring Libraries
  • Updating to Refactored Libraries

JavaScript, Python, and dynamic languages in general do well in some of these areas but not others

For example, “Writing New Code” seems to be the area of focus for advocates of dynamic languages, who see a big power gain there, and possibly in “Learning the Language”.

It seems to me, however, that Java is just as powerful as dynamic languages in the other categories, and much more powerful if you use an IDE with support for completion and refactoring.

That is to say, I can get a hell of a lot more refactoring done per unit of time in Java using Eclipse than I’ve seen in any other language.

This post was inspired this other blog post that compares using GWT to Javascript:

Debugging GWT AsyncCallback issues by adding a timeout

October 21, 2007

In my GWT code I tend to end up with AsyncCallbacks all over the place so that I can support data which is fetched via RPC in all my widgets.  It seems to be a commonplace issue that I forget to call the callback, which can be quite difficult to diagnose.  To help with that I create a class which “times out” an AsyncCallback.  You wrap your AsyncCallback in this object and then you’ll get an error back if no failure or success comes back in a timely fashion.

GWT to EJB Bridging

August 1, 2007

I recently figured out that I could save myself a lot of hassle by implementing my GWT service/servlet in a bean. Once it’s a bean, all its methods are automatically wrapped in a transaction, which keeps my code really clean. Previously I didn’t think this was possible without having a ton of delegate methods in the servlet. However, I’ve discovered that I can just have my servlet dispatch client requests directly to a bean by overriding processCall(). Read the rest of this entry »

Tip: In GWT, VerticalPanel could be replaced with FlowPanel

July 29, 2007

I’ve been fighting with a lot of layout issues over the last few hours that are caused by differences between the way IE and Firefox handle table widths. IE seems to expand tables whether I like it or not, which is a pain. VerticalPanel uses a table to line elements up vertically.

I’ve started trying FlowPanel as an alternative; FlowPanel inserts elements without any wrapping (they just go into the parent element), which means that if any element is a block element, they’ll all be put into blocks and stacked vertically, just like VerticalPanel but without the tables.