grails – hasMany does not generate dynamic properties

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!

4 Responses to “grails – hasMany does not generate dynamic properties”

  1. Amrit Hallan Says:

    Hi Sanjay.

    Sorry for the off-topic comment here — couldn’t find a contact page/link.

    I’m preparing an online blog directory of blogs being maintained by Indians and people of Indian origin. Whenever you get some time, please submit a few details at

    Please forward this message to other bloggers if you think they’ll be interested.


  2. sapna Says:

    Bollywood News, Bollywood Gossips, Indian Actress and Actresses are the best place to know about Indian entertainers who can just reach all bollywood quality.

    Bollywood News, Bolloywood Gossips, Indian Actress, Indian Actresses, Bollywood Heros, B
    Bollywood News, Bollywood Gossips, Indian Actress and Actresses are the best place to know about Indian entertainers who can just reach all bollywood quality.

  3. best car finance deals Says:

    Loans4 provide homeowner loan solutions for homeowners.
    In the past they have included such things as toys, rattles, bibs, and tethers.
    The Teamster Union, handling the bargaining negotiations
    for UPS worker-members, made a careful study of this particular issue and decided to launch a major offensive strike against

  4. Radio Orange Pre Pay Mobiles Says:

    I ⅼove reading through an article that can make people
    think. Also, thanks for peгmitting me to comment!

Leave a Reply