Archive for May, 2010

GWT and NetBeans

In this post we will set up Netbeans to support a GWT Project using the gwt4nb plugin. Note that there is also the Google plugin for Eclipse.

First off, download and install the gwt4nb plugin.

In Netbeans, create a new Java Web –> Web Application. Name your application and hit Next until you get to the Frameworks tab. If you have successfully installed the gwt4nb plugin you should see Google Web Toolkit listed. Select the Google Web Toolkit framework. Then, if you haven’t already, download the GWT SDK. Next, browse to the GWT SDK installation folder. Name your GWT module and hit Finish.

The plug-in will create a gwt.xml file which references the GWT entry point implementation class.

For example, if I used the module name com.codenes then I would see the file codenes.gwt.xml created in the com package under Source Packages. The entry point implementation class reference would read as:

<entry-point class=”com.client.codenesEntryPoint”/>

We can locate the entry point implementation class within the newly created com.client package. Inspecting this class, we can see the entry point method onModuleLoad() which is where we will be adding our own code later. Inside the method we can see a button and a label are being created and added to the RootPanel.

Run the project, your browser should launch and the button “Click me!” and the text “Hello, GWT!!!” should be visible.


I’m currently porting an AJAX style web application written entirely in Javascript, to a Google Web Toolkit (GWT) web application written in Java.  I’m doing this because I am no Javascript guru and I wanted to further extend the original project so it was either now or never to make the more comfortable switch to Java. The other reason is the web application needs to work with a lot of complex XML as it interacts with SOAP web services. To this point, I haven’t found a Javascript equivalent of XMLBeans which does a fine job of binding XML schemas to Java objects.

The original Javascript web application used the following libraries:

  • Ext JS – Javascript framework for UI/widgets (licensed)
  • OpenLayers – Javascript library for displaying dynamic maps (open source)
  • Apache CXFWSDL2JS tool for generating Javascript web service client stubs (open source)

The GWT equivalent libraries that I am using for the ported project are:

  • Ext GWT – Java framework for UI/widgets (licensed)
  • GWT-OpenLayers – GWT wrapper for OpenLayers (open source)
  • Metro/JAX-WS – Wsimport tool for generating Java web service client stubs (open source)

The development environment for the original Javascript project was Netbeans (6.5) for coding, AppServ (Apache web server) for deployment and the Firefox Firebug plugin for debugging.

The ported Java project is being developed entirely in Netbeans (6.7.1), using the bundled Glassfish application server and GWT Hosted Mode within the IDE for debugging.

From an architecture point of view, the GWT project is going to be a little different from the original Javascript application. The Javascript application made client side AJAX/XMLHttpRequest calls to a variety of web services.

Note. To support Javascript cross-site scripting you can configure Apache web server using the mod_rewrite/proxy method detailed in this post

The GWT project on the other hand, will utilise GWT’s Remote Procedure Call (RPC) mechanism to decouple GWT client-side and server-side code. The client-side code will be the presentation layer (UI) and will make RPC calls to the server-side code which will consume a variety of web services, returning the response back to the client-side for presentation.