2013-06-09 12:19:58

2012-08-10

Grails error message in Cinnamon Entitylib

Setup

Grails 1.3.1

Java 6

Java Domain classes with JPA 1

Project: Cinnamon / Entitylib and AdminTool (Dandelion): cinnamon-cms.de

Problem description

A normal call to load a GORM object (Java Domain class) fails with a strange error message:

java.lang.NullPointerException: Cannot invoke method isAssignableFrom() on null object
at java_lang_Class$isAssignableFrom.call(Unknown Source)
at eu.hornerproject.dandelion.IndexTypeController$_closure5.doCall(IndexTypeController.groovy:75)
at eu.hornerproject.dandelion.IndexTypeController$_closure5.doCall(IndexTypeController.groovy

The code in question:

1
    def indexTypeInstance = IndexType.get(params.id)

params.id contains a valid id.

The IndexType class is mapped.

Note that there is absolutely no hint as to what causes this problem - java.lang.Class is called from an unknown source, and stepping through to it by debugger is a quite impractical, because Grails / Groovy does so many things during the IndexType.get() step that you will probably die of old age before you find the problem.

(Probable) Cause & Solution

The IndexType class was missing getters and setters, and I guess the later ones are being used by GORM to set the indexerClass- and vaProvider-class fields.