Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.0 final
-
Fix Version/s: 2.0.4
-
Component/s: Controllers
-
Labels:
Description
I always used g.eachError(bean: instanceName) in my controllers (and also in services) in Grails 1.3.7 and it worked like a charm. After an upgrade to Grails 2.0.0 it seems that g.eachError(bean: instanceName) doesnt work anymore.
Here the errormessage from the grails-error page / stacktrace in netbeans:
Error 500: Internal Server Error
URI: /savetest/test/save
Class: java.lang.NullPointerException
Message: null
Around line 22 of grails-app/controllers/savetest/TestController.groovy
NullPointerException occurred when processing request: [POST] /savetest/test/save - parameters:
vorname:
test: test
name:
Stacktrace follows:
Message: null
Line | Method
->> 22 | doCall in savetest.TestController$_closure2$$ENLSCNLc
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
886 runTask in java.util.concurrent.ThreadPoolExecutor$Worker 908 run . . in ''
^ 680run in java.lang.Thread
//Stacktrace taken from the error.gsp (extended it with the whole code)
18: if(testInstance.save())
else { //Constraint errors, prepare JSON response with error messages.
21: //This doenst work anymore
22: g.eachError(bean: testInstance) {
23: postResponse.errors."$
24: }
25: //This one works perfect, but seems inefficient to me
26: testInstance.errors.allErrors.each {
27: //Do Something with the error
28: postResponse.errors."${it.field}
" = g.message(code: "$
{testInstance.class.name}.$
{it.field}.$
{testInstance.errors.getFieldError(it.field).code}.error")
29: }
It seems to me that the non persisted domain objects causes this error. But i am not 100% sure.
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits
| Field | Original Value | New Value |
|---|---|---|
| Assignee | Lari Hotari [ lhotari ] |
| Last Reviewed | 01/Jan/10 |
| Workflow | Grails2 [ 87169 ] | jira [ 89014 ] |
| Workflow | jira [ 89014 ] | Grails2 [ 97162 ] |
| Fix Version/s | 2.0.4 [ 13099 ] |
| Status | Open [ 1 ] | In Progress [ 3 ] |
| Status | In Progress [ 3 ] | Resolved [ 5 ] |
| Resolution | Fixed [ 1 ] |