Domingo (7) [Avatar] Offline
#1
Hi,

I'm going through Grails in Action using Grails 2.0.0-RC1. It's rather smooth so far. The first obstacle that I noticed is a comman object (listing 5.13) that doesn't work. When pointing browser to register2 action I get:

URI
/hubbub/user/register2
Class
java.lang.IllegalArgumentException
Message
object is not an instance of declaring class

Line | Method
->> 101 | doCall in com.grailsinaction.UserRegistrationCommand$__clinit__closure1$$ENI6ld3w
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 26 | doFilter in DevModeSanityFilter.groovy
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread

which, if I clearly interpret the message, means that binding doesn't work for register2 action in the controller:

def register2 = {UserRegistrationCommand urc ->
if (urc.hasErrors()) {
...
}

I tried with both closure and method as controller action (introduced in Grails 2) but the effect is the same. Any hints?
Domingo (7) [Avatar] Offline
#2
Re: Chapter 5: Command objects under Grails 2.0.0-RC1
Hi, I returned to this issue because in other places where Command objects were used, they worked perfectly for me. So after investigating my issue more deeply I found a typo in my Command object, i.e.:

class UserRegistrationCommand {
...
String fullName
...

static constraints = {
...
fullname(nullable: true) // should be fullName
}
}

Pity that the message was completely missleading.