Cannot Invoke Method isAssignableFrom() on Null Object


Grails error message in Cinnamon Entitylib


Grails 1.3.1

Java 6

Java Domain classes with JPA 1

Project: Cinnamon / Entitylib and AdminTool (Dandelion):

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$ Source)
at eu.hornerproject.dandelion.IndexTypeController$_closure5.doCall(IndexTypeController.groovy:75)
at eu.hornerproject.dandelion.IndexTypeController$_closure5.doCall(IndexTypeController.groovy

The code in question:

    def indexTypeInstance = IndexType.get( 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.