History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: GRAILS-1672
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Blocker Blocker
Assignee: Graeme Rocher
Reporter: Dave Syer
Votes: 3
Watchers: 4
Operations

If you were logged in you would be able to see more operations.
Grails

NullPointerException using findAll() before get()

Created: 04/Oct/07 05:36 AM   Updated: 30/Nov/07 07:19 AM
Component/s: Persistence
Affects Version/s: 1.0-RC1
Fix Version/s: 1.0-RC2

Time Tracking:
Not Specified


 Description  « Hide
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)
...



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
dan stadler - 10/Nov/07 07:27 AM
first-time poster here, please inform me of any etiquette or protocol violations I may be committing...

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.