Installing the MigLayout Plugin for Griffon

The usual install-plugin method hangs, therefore this is what I did to install the MigLayout plugin in my Griffon Application:

  1. Check out the latest source code of the plugin from this repository.
  2. On the command line change into the source code folder
  3. Execute griffon package-plugin
  4. On the command line change into the project folder of your Griffon project
  5. Execute install-plugin <path to the newly compiled plugin>

That’s it, worked like a charm for me.

MySQL Cheat Sheet

Connecting to a DB:

mysql -u username -p database_name
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 222
Server version: 5.1.44 Source distribution
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

Simple Query

| id | version | code | with_phonetics |
|  1 |       0 | Cn   |               |
|  2 |       0 | En   |                |
|  3 |       0 | Jp   |               |
|  4 |       0 | De   |                |
4 rows in set (0.38 sec)

Creating a New Database

mysql> CREATE DATABASE new_name_db;
Query OK, 1 row affected (0.07 sec)

Creating a New User

mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass'; 

Granting User Rights

mysql>GRANT ALL PRIVILEGES ON  mydbname.*  TO  someuser;

Changing to Another Database

mysql> USE new_name_db;
Database changed

Deleting a Database

mysql> DROP DATABASE some_db; Query OK, 1 row affected (0.00 sec)

Database Dump

mysqldump -u root -p dbname > filename

Import a Dump

mysql -u username-p password database_name < filename.sql

Altering a Table

ALTER TABLE some_table MODIFY some_number FLOAT(11) NOT NULL DEFAULT 0;

Problem with Grails Integration Test in IntelliJ IDEA

I tried to test a Grails Service with an Integration Test in my beloved IDEA IDE – sometimes it worked as expected, sometimes the service was not injected and the test failed with a Null Pointer Exception.

It took me a while to figure out that the problem is related to the Run /Debug configuration. When IDEA applies a Run/Debug configuration in which the Integration Test is assigned to the Unit Tests Configuration, the Test is treated exaclty us such and consequently the Service is not injected.

The solution to the problem is therefore to make sure that your Integration Test is running inside the Grails Configuration in IDEA.

Grails and the Burning-Image Plugin on Windows

The Grails part is straight forward as documented. As for the Windows environment make sure that you have the jmagick.dll in your <JDK>/jre/bin directory and the jmagick.jar in the <JDK>/jre/lib directory.  Also make sure that the core_rl_magick_.dll is installed on your system. You can do so by downloading and installing an ImageMagick version that contains the dlls, e.g. ImageMagick-6.3.9-0-Q16-windows-dll.exe.

Grails and smartgwt

To set up a grails and smartgwt project basically follow this great tutorial by Peter Ledbrook.
The equally useful tutorial by Josip goes one step further.

1) Create a grails project

2) Install the gwt plugin

3) Install the smartgwt plugin

4) Create a module

5) Fill in the entry point: Create the DataSource and Form Classes. Attention: If you use Josips tutorial make sure that in the function

the formWindow.setHeaderControls(HeaderControls.HEADER_LABEL, closeControl); methode is called first thing before any of the other formWindow.set(..) methods, otherwise you get am IlegalStateException.
Check if the url to the controller that are called from within your RestDataSource are correct.

6) Inherit from smartgwt

7) Generate the gsp page that holds the gwt client and move it from the web-app to the grails-app/view directory.

8) Remove the grails main.css from the layout/main.gsp  page

9) Add

<script>var isomorphicDir = "gwt/org.example.SmartButton/sc/"</script> to the main.gsp page but leave gwt/ as is!

10) Alter the url mapping so that the gsp page holding the gwt client is loaded by default.

11)  Run the compile gwt module command

12)  Fire up grails and fire up the gwt-client

Grails and GWT in IntelliJ’s IDEA: Not a valid GWT installation Error

The other day I treated myself to a license of IntelliJ’s IDEA and I am loving it especially when working with Grails projects.

When I started toying around with the GWT plugin for Grails however, I ran into trouble because apparently the GWT_HOME environment variable that I defined for the bash shell is not visible to IDEA which results in a nasty ERROR: null is not a valid GWT installation show stopper – among others.

To solve the problem I created the file ~/.MacOSX/environment.plist and edited it so that it looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0">

In IDEA’s Run Debug configuration make sure that the include parent environment variables option is selected.
In this way any environment variable defined in the file environment.plist is passed to applications that are started from the finder such as IDEA.

Instead of defining GWT_HOME for the finder I could have added it to IDEA’s Run / Debug Configurations but the downside to this solution is that any script triggered by Run Target that depends on environment variables such as run-gwt-client would fall flat again.

Grails 1.3.6 Bug in jquery Tag: Page Reqeuest Instead of AJAX Call

There is a bug in Grails 1.3.6 that prevents (at least) the remoteLink to work correctly. Instead of calling the specified controller closure as an AJAX call, a normal page request is conducted resulting in a futile attempt to display a page on the part of the server.

Downloading the latest Grails 1.3.7-SNAPSHOT release solved the problem for me.

ActionsScript 3: Calling nonexisting methods

I have been wondering all along how it is possible to call a method that is not defined anywhere in that class and get something reasonable done, e.g. the method on the Cairngorm delegate that conducts the call to the server.

After playing around with Grails I became aware of the fact that this mechanism is used extensively not only in Grails but in other frameworks that are based on dynamic languages such as Ruby on Rails.

This great blog entry on lifts the veil and explains the magic.

Grails App-Engine deployment

When deploying a new version of my application (actually I started an entire project from scratch) I continuously bounced my head against this  “You don’t have the permission…” exception.

I finally added the following lines to my Configuration/config.groovy file:


where myproject is the part that appears in the url, like

Google App-Engine, Grails and Security

Here are the directions for a patch in a great Screencast by Tomás Lin that makes authentication work  in a Grails Application on Google’s App-Engine:

google.appengine.sessionEnabled = true // default true
google.appengine.enableSsl = true // default true = ["/secure", "/shoppingcart/*", "/admin"] = ["/admin", "/notsecuredadmin"] = ["/admin", "/", "/yabbadabbadoo"]

Don’t forget to apply the securePatch.diff patch to the plugin directory of your project – that is in <home>.grails/1.1.1/projects/myproject/plugins/app-engine-0.8.1 in order for these properties effectively written to the web.xml file.

Google App-Engine and Grails Dynamic Methods

A blog entry about running grails on Google’s App Engine. Among other things the methods that are provided by the App-Engine plugin are listed.

The added domain class MetaClass methods are:

  • save
  • get
  • delete
  • findAll
  • withTransaction
  • withPersistenceManager (to execute code with access to the PersistenceManager)
  • isJdoPersistent, isJdoDeleted, isJdoDetached, isJdoDirty, isJdoNew, isJdoTransactional, getJdoTransactionalObjectId, getJdoVersion, getJdoObjectId, and jdoMakeDirty corresponding to the JDOHelper methods isPersistent, isDeleted, isDetached, isDirty, isNew, isTransactional, getTransactionalObjectId, getVersion, getObjectId, and makeDirty

Controllers have these attributes added to their MetaClass:

  • params (with Request attributes like in Grails)
  • session
  • request
  • response
  • servletContext

Google AppEngine Data Store explained

Since the Data Store behind Google’s AppEngine is not a relational database I have been wondering all along how to manage one-to-many and many-to-many relationships. This links to the Java documentation:

And here are some well explained examples in Python:

Connecting NetBeans 6.7 to SVN on Ubuntu

These are the steps I had to take to establish a connection from within NetBeans 6.7 to my Subversion Repository via a https connection.

Install svn -> sudo apt-get install svn
Install an svn client, I chose RapidSVN -> sudo apt-get install rapidsvn
In NetBeans select Team > SVN>Check out… and fill in the Form. The path to the RapidSVN executable is /usr/sbin.
Restart NetBeans and you should be able to proceed in the wizard.

Mercurial and SSH-2 DSA on Windows XP

After installing Mercurial and TortoiseHG on Windows XP I subscribed to the SCM Hosting provider and so far I am very pleased with their service. The subscription process was straight forward, the repository usable within minutes after subscribing and all of that for a very affordable price, I might add.

I had fun exploring Mercurial as a next generation distributed source code management system – until I hit that SSH wall, that is.  So here is a short description how to configure SSH on Windows XP:

  1. Download and install putty-0.60-installer.exe.
  2. Fire up the  PuTTY Key Generator, chose SSH2-DSA and fill in the form.
  3. Save the private key to a file.
  4. Copy the public key as it appears in the text area field (including the first line) to the server.
  5. Start up Pageant – if its running, an icon with a computer wearing a heat is visible in the system tray. Right-click on that icon and select “Add Key”.
  6. Tell Pageant where to find your private key.
  7. Append the follwoing line to the [ui] section of your .mercurial.ini file:
    ssh="/path/to/plink.exe" -ssh -i "/path/to/your/private/key"

Done! You should be able to clone and push to your server.

Intercultural Differences on the Internet

This article published by the Swiss weekly SonntagsZeitung in German describes the research conducted by Katharina Reinecke from the Universiyt of Zurich about how web sites differ significantly in style and structure in various cultures. She found out about this gap while developing an e-learning system for farmers in Rwanda.

is the most successful search engine in Korea. Because Google Korea failed miserably they tried to adapt there simplistic design  to the Korean taste with a more lively and colorful version.

Groovy and JPA

Tutorial about how to use Hibernate from within Groovy making use of Groovy Templating:

import javax.persistence.*

class JpaTemplate {

    EntityManagerFactory emf

    EntityManager em

    JpaTemplate(pu) {
        if (!pu) pu = "default"
        emf = Persistence.createEntityManagerFactory(pu)

    void doInEntityManager(c, shutdown) {
        em = emf.createEntityManager()
        if (shutdown) shutdown()

    void shutdown() {

And here is how to use the template that was defined above:

new JpaTemplate().doInEntityManager({ em ->
    em.createQuery("delete Contact").executeUpdate()
    em.persist new Contact(name:'Dan Allen', email: '')
}, true)

Expression Language Tricks

1. Concatenation: Looking up a composite key in a dictionary


2. Conditional composite String output

#{condition?’ok': messages[‘ex.pression1′].concat(‘  ‘).concat(messages[‘ex.pression2′])}

3. Projections: Looping over a collection and printing one field



Source: Seam Documentation