NullPointerException using findAll() before get(). You don't see this in a vanilla CRUD application, but it's easy to reproduce in my app using the console. All domain objects suffer from the same problem
X.get(0)
X.findAll()
is fine
but if you do X.findAll() before any other calls to X you get
java.lang.NullPointerException
at org.codehaus.groovy.runtime.DefaultGroovyMethods.findAll(DefaultGroovyMethods.java:1187)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:59)
at org.codehaus.groovy.runtime.NewInstanceMetaMethod.invoke(NewInstanceMetaMethod.java:91)
...
anyway, I just wanted to report that I'm getting this same problem with RC-2, which I downloaded on Nov 8 2007.
For me it's happening when I use the ZK list.zul from the ZK plugin demo (i.e.:
http://grails.codehaus.org/ZK+Plugin
)
I've tweaked the zul page just enough to talk to one of my domain classes:
<?xml version="1.0" encoding="UTF-8"?>
<?page zscriptLanguage="Groovy"?>
<window border="normal" title="Groovy Card Test" id="MainWindow" width="400px">
<zscript>
cards = Card.findAll()
</zscript>
<listbox>
<listhead>
<listheader label="ID"/>
<listheader label="Cardtext"/>
</listhead>
<listitem forEach="${cards}">
<listcell label="${each.id}"/>
<listcell label="${each.cardtext}"/>
</listitem>
</listbox>
</window>
, and if I haven't yet navigated through my scaffolded tools to look at card data, i.e. I just run the ZK page first, then I get the same 500 error:
2007-11-10 14:15:58.847::WARN: /grails-zk/list.zul
java.lang.NullPointerException
at org.codehaus.groovy.runtime.DefaultGroovyMethods.findAll(DefaultGroovyMethods.java:1187)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.codehaus.groovy.reflection.CachedMethod.invokeByReflection(CachedMethod.java:107)
etc etc.
but once I've navigated to some cards in the scaffolded pages, then the zul page works great.