GWT – Common Problems with Solutions

Wednesday, October 26, 2011 Labels: , , , , ,
I'll start by saying that I'm not a massive GWT fan, but yes there are many who are. That’s why I come up with some solutions to some common problems associated with GWT.

Problem: Long compile times, as your project grows so does the amount of time it takes to compile it. I've heard of reports of 20 minute compiles, but mine are on average about 1 minute.

Solution: Split your code into separate modules, and tell ant to only build it when it's changed. Also while developing, you can massively speed up compile times by only building for one browser. You can do this by putting this into your .gwt.xml file:

<set-property name="user.agent" value="gecko1_8" />

Where gecko1_8 is Firefox 2+, ie6 is IE, etc.

Problem: Hosted mode is very slow (on OS X at least) and does not come close to matching the 'live' changes you get when you edit things like JSPs or Rails pages and hit refresh in your browser.

Solution: You can give the hosted mode more memory (I generally got for 512M) but it's still slow, I've found once you get good enough with GWT you stop using this. You make a large chunk of changes, then compile for just one browser (generally 20s worth of compile) and then just hit refresh in your browser.

Update: With GWT 2.0+ this is no longer an issue, because you use the new 'Development Mode'. It basically means you can run code directly in your browser of choice, so no loss of speed, plus you can firebug/inspect it, etc.

Problem: GWT code is java, and has a different mentality to laying out a HTML page, which makes taking a HTML design and turning it into GWT harder

Solution: Again you get used to this, but unfortunately converting a HTML design to a GWT design is always going to be slower than doing something like converting a HTML design to a JSP page.

Problem: GWT takes a bit of getting your head around, and is not yet mainstream. Meaning that most developers that join your team or maintain your code will have to learn it from scratch

Solution: It remains to be seen if GWT will take off, but if you're a company in control of who you hire, then you can always choose people that either know GWT or want to learn it.

Problem: GWT is a sledgehammer compared to something like jquery or just plain javascript. It takes a lot more setup to get it happening than just including a JS file.

Solution: Use libraries like jquery for smaller, simple tasks that are suited to those. Use GWT when you want to build something truly complex in AJAX, or where you need to pass your data back and forth via the RPC mechanism.

Problem: Sometimes in order to populate your GWT page, you need to make a server call when the page first loads. It can be annoying for the user to sit there and watch a loading symbol while you fetch the data you need.

Solution: In the case of a JSP page, your page was already rendered by the server before becoming HTML, so you can actually make all your GWT calls then, and pre-load them onto the page, for an instant load. See here for details:


Eric Jablow said...

You should write your code to use concrete classes instead of interfaces too, unlike normal Java practice. If you write a method with signature public BigDecimal getTotalPrice(List<LineItem> items), GWT may end up translating ArrayList, LinkedList, and every other implementation of List that your application might theoretically use. See Ray Ryan's presentation for details.

admin said...

very good suggestion and practice for GWT applications
I completely agree with you

Igor Polevoy said...

Converting HTML to complex GWT design is made easy with uibinder. This allows pixel perfect HTML to be used that was produced by a designer. No longer do you have to be at the mercy of HTML generated by GWT widgets

admin said...

yes its easy using uibiner and you can use HTMLPanle in jsps as HTMLPanel is a div-based widget that lets you add HTML elements and, if they have an ID, lets you add and remove widgets to these elements.

Unknown said...

Hi everyone.........Please Help me

I am facing following problem while gwt compilation

A fatal error has been detected by the Java Runtime Environment:
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000005cc5d158, pid=4732, tid=3032
# JRE version: Java(TM) SE Runtime Environment (7.0_75-b13) (build 1.7.0_75-b13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.75-b04 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# V [jvm.dll+0x49d158]
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
# If you would like to submit a bug report, please visit:

Post a Comment

Waqas Sadiq © 2014