This is a technical post, I should probably create another site for such things.

Just want to document some problems I came across while trying out some examples from The Definitive Guide To Grails…

class Bookmark {

    static hasMany = [tags:Tag]
    URL url
    String title
    String notes
    Date dateCreated = new Date()

class Tag {

        static belongsTo = Bookmark
        Bookmark bookmark
        String name

b = new Bookmark(
        url: new URL(‘’),
        notes:’Groovy-based web framework’)

b.addTag( new Tag(name: ‘grails’) )

These simply did not work, giving the error MissingMethodException, and basically the dynamic methods just weren’t being generated.

To cut a long story short, here are some things that solved the problem:

– In the Groovy plugin for eclipse – Eclipse->Project->Properties->Groovy Project Properties->Turn of the Groovy compiler.

– Disable automatic build in Eclipse, which generates unnecessary classes, that overwrite the groovy dynamically generated classes.

A cryptic error while running from Eclipse :

Cannot execute native2ascii failed.
This can be resolved by running grails runapp once, which does the conversion of native to ascii initially.

Most of the above solutions were at though it still involved quite a bit of searching!

If these issues are not sorted out in the development environment,
then one may consider using Eclipse only as an editor, using the command line for grails!

A key point is that the hasMany relationship has been revised as described in GORM – Defining relationships, making addTag deprecated, changed to addToTags

In case anyone has just typed in the code into a groovy console, it might not work as the classes should be defined as proper domain classes using create-domain-class target.

Having programmed for over 10 years in C, C++, COM, DCOM, STL, MFC and .NET right from its pre-beta stage of evolution, as well as Java right from 1.0 in college days, I find Groovy on Grails defining the future of technology. Its based on a very impressive solid foundation (of JVM, Hibernate, Spring) Want to write in more detail later sometime but anyway there’s already enough available out there already!