Archive for category General

GraniteDS Flex Plugin

There is a surprising lack of Grails –> Flex integration available. There is a flex plugin available on, however it is experimental and was really only written as a proof-of-concept. The plugin allows you to annotate your service classes in Grails, so that the services become “remotable” during run time.

I was looking for a way to communicate between Grails and Flex using the Adobe native AMF3 protocol. I found way to do it using the GraniteDS Flex Plugin. Brilliant that somebody thought of this!

Using AppEngine Logging with the Grails AppEngine Plugin

Grails is all about convention-over-configuration, and in most cases that idea works just fine. Sometime that idea isn’t so great.

The Grails App engine plugin provides an example of this. When packaging and deploying a new version of your app, the grails appengine task generates the appengine-web.xml file for you automatically. This file is used by Google App Engine to configure your app. The problem I faced recently is that I needed to make a change to this file, and there was no way to do it without modifying the GANT task that generates the file. Which is what I did.

In my case I wanted to enable the handy logging mechanism provided by Google AppEngine. GAE uses the java.util.logging framework to accomplish this as documented here.

I copied the file to: MY_GRAILS_APP/web-app/WEB-INF

Then to point to my file, I had to modify the GANT task that generates the appengine-web.xml file.


I modified the section that stamps out the appengine-web.xml file to look like this:

println "Generating appengine-web.xml file for application [$appName]"	
	new File("$stagingDir/WEB-INF/appengine-web.xml").write """<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="">
	    <!-- this property should be necessary. it avoids the report of an abnormal and unexpected situation!
	        <property name="appengine.orm.disable.duplicate.emf.exception" value="true" />
	     <property name="java.util.logging.config.file" value="WEB-INF/"/>

After running a grails app-engine deploy, the new version of the app was deployed and the log messages came through in my Google App Engine Dashboard.

Perhaps in future releases of the grails app engine plugin, a better way will be provided to make changes to the appengine-web.xml file.

Using the Google App-Engine Plugin for Grails

Like Rails, Grails can be configured with plugins. There is an entire repository at Many of the plugins are very helpful, such as the Grails Google App Engine Plugin.

I used the plugin to create and deploy a web site for my company, Clearbox Consulting. The plugin made the entire process that much easier.

Google App Engine is simply awesome. It provides persistence, logging, version control, statistics and many other cool features. Check it out.

I really don’t need to be running a grails-enabled web site, hosted via google appengine just yet. For now I am only serving up static content. But I figured it wouldn’t hurt to get Grails setup, so that ini the future I can add more enhanced functionality.

Executing Shell Commands in Groovy

In Java, to execute a shell command, I would use something like this:

public class ExecuteCommand
   public static void main(String[] args)
         Process proc = Runtime.getRuntime().exec("set" );
         BufferedReader result = new BufferedReader(
         new InputStreamReader(proc.getInputStream()));
         String line;
         while((line = result.readLine()) != null)
      catch(IOException ex)

The same thing can be done in Groovy with the following one-liner:

println "set".execute().text

The day I discovered Groovy

Groovy has changed my life. At least my life as a software engineer. After many years of Java programming, I was disenchanted with the language’s restrictiveness. I delved into Ruby to find solace in dynamic languages and I found that I wasn’t exactly happy switching completely out of the Java paradigm. Especially when it came to constructing Enterprise-level applications. Well… along came Groovy… and my world has changed. Closures, Dynamic Typing and many other features that allow you to get things done quicker… and it all runs within the JVM. Brilliant…

Here are some cool examples of looping mechanisms in Groovy:

0.upto(4) { print "$it " }


0 1 2 3 4


Welcome to

It’s about time I started to collect my thoughts into one place. Besides, I’ve benefited greatly during the course of my career as a software engineer from the random musings, hints, fixes, and tips posted by other software engineers out there. So I think it is about time I gave something back.