grails命令对象中出现错误

grails命令对象中出现错误,grails,Grails,这个错误的奇怪之处在于,有时页面会生成错误,有时则不会。我不知道是什么原因或原因: errors.GrailsExceptionResolver ClassCastException occurred when processing request: [GET] /birthFamily/aboutYouLifestyle java.util.LinkedHashMap cannot be cast to groovy.lang.Closure. Stacktrace follows: java

这个错误的奇怪之处在于,有时页面会生成错误,有时则不会。我不知道是什么原因或原因:

errors.GrailsExceptionResolver ClassCastException occurred when processing request: [GET] /birthFamily/aboutYouLifestyle
java.util.LinkedHashMap cannot be cast to groovy.lang.Closure. Stacktrace follows:
java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to groovy.lang.Closure
    at com.nrfa.LifestyleCommand$__clinit__closure1.doCall(Wizard.groovy:302)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)
有问题的命令对象:

@Validateable
public  class LifestyleCommand {
    Integer applicantNumber;
    Smoke smoke
    Drink drink
    Occupation occupation
    Set <String> hobby
    String occupationDetails

    static constraints = {
        importFrom Applicant, include:["smoke", "drink", "occupation", "occupationDetails", "applicantNumber"]
    }
}
编辑:

以下是申请人的相关部分,它是域对象:

class Applicant {

    static hasMany = [hobby:Hobby, ethnicity:Ethnicity]

    Integer applicantNumber
    String gender
    Integer yearBorn
    EyeColor eyeColor
    HairColor hairColor
    Integer heightFeet
    Integer heightInches

    static constraints = {
        applicantNumber (blank:false, nullable:false, range:1..2)
        gender (blank:true, nullable:true, validator: { value ->
            if (value != null && value != '' && (value != "M" && value != "F")) {
                return 'applicant.invalid.gender'
            }
        })
        yearBorn (blank:true, nullable:true, validator: { value ->
            if (value != null && (value < 1920 || value > 2014)) {
                return 'applicant.invalid.yearBorn'
            }
        })
        eyeColor (blank:true, nullable:true)
        hairColor (blank:true, nullable:true)
        smoke (blank:true, nullable:true)
        drink (blank:true, nullable:true)
        heightFeet (blank:true, nullable:true, validator: { value ->
            if (value != null && (value < 3 || value > 7)) {
                return 'applicant.invalid.heightFeet'
            }
        })
        heightInches (blank:true, nullable:true, validator: { value ->
            if (value != null && (value < 1 || value > 12)) {
                return 'applicant.invalid.heightInches'
            }
        })
    }
}
班级申请人{
静态hasMany=[爱好:爱好,种族:种族]
整数应用程序编号
字符串性别
整年出生
眼色
发色发色
整数高度英尺
整数高度英寸
静态约束={
申请编号(空白:false,可空:false,范围:1..2)
性别(空白:true,可空:true,验证器:{value->
如果(值!=null&&value!=''&&value!=“M”&&value!=“F”)){
返回“申请人。无效。性别”
}
})
yearBorn(空白:true,可空:true,验证器:{value->
如果(值!=null&(值<1920 | |值>2014)){
返回“申请人。无效。出生年份”
}
})
eyeColor(空白:真,可空:真)
头发颜色(空白:真,可空:真)
烟雾(空白:真,可空:真)
饮料(空白:真,可空:真)
heightFeet(空白:true,可空:true,验证器:{value->
如果(值!=null&(值<3 | |值>7)){
返回“申请人。无效。身高英尺”
}
})
高度英寸(空白:真,可空:真,验证器:{value->
如果(值!=null&(值<1 | |值>12)){
返回“申请人。无效。高度英寸”
}
})
}
}
向导是我的控制器。有一个处理表单请求的操作,表单请求提交要填充到Lifestyle命令对象中的数据。我只是在没有填写任何字段的情况下提交页面,所以所有内容都是null/空的,这是有效的


我正在运行grails 2.2.4

正如评论中指出的那样,您可能应该删除
职业
职业详细信息
包含
生活方式命令的
约束(在
申请者
中没有该字段的约束)。

您也可以按原样发布
申请者
吗,在问题中?什么是
Wizard.groovy
?它似乎试图将importFrom的“include”部分强制转换为“last-argument”闭包。但是,这没有意义,因为importFrom在添加到2.0.2(根据文档)后接受了include list参数,我想看看这个绑定存在哪些参数,以及正在使用的Grails的哪个版本。我已经添加了申请者域,并提供了向导代码的说明。您在
申请者
中没有
职业
职业详细信息
及其约束吗?
class Applicant {

    static hasMany = [hobby:Hobby, ethnicity:Ethnicity]

    Integer applicantNumber
    String gender
    Integer yearBorn
    EyeColor eyeColor
    HairColor hairColor
    Integer heightFeet
    Integer heightInches

    static constraints = {
        applicantNumber (blank:false, nullable:false, range:1..2)
        gender (blank:true, nullable:true, validator: { value ->
            if (value != null && value != '' && (value != "M" && value != "F")) {
                return 'applicant.invalid.gender'
            }
        })
        yearBorn (blank:true, nullable:true, validator: { value ->
            if (value != null && (value < 1920 || value > 2014)) {
                return 'applicant.invalid.yearBorn'
            }
        })
        eyeColor (blank:true, nullable:true)
        hairColor (blank:true, nullable:true)
        smoke (blank:true, nullable:true)
        drink (blank:true, nullable:true)
        heightFeet (blank:true, nullable:true, validator: { value ->
            if (value != null && (value < 3 || value > 7)) {
                return 'applicant.invalid.heightFeet'
            }
        })
        heightInches (blank:true, nullable:true, validator: { value ->
            if (value != null && (value < 1 || value > 12)) {
                return 'applicant.invalid.heightInches'
            }
        })
    }
}