Grails 缺少属性异常
我遇到了一个奇怪的错误,导致我整个上午都挂断了电话。我有一个带有 Person 类的 Grails 应用程序,如下所示:
class Person {
String id
Date lastUpdated
String note
String lastName
String firstName
String middleName
String facility
...
}
在我的控制器中,我有一个闭包来获取模型:
def personDetail = {
Person person = new Person()
...
List<Person> personSearchList = session.getAttribute("searchResults")
Person selectedSearchPerson = selectedSearchPersonList.find { it.id == selectedID }
person.firstName = selectedSearchPerson.firstName
person.lastName = selectedSearchPerson.lastName
person.middleName = selectedSearchPerson.middleName
person.facility = selectedSearchPerson.facility
...
return [person:person]
}
现在,这段代码昨天工作正常。然而,今天早上,在没有进行任何修改的情况下(我什至尝试恢复到较旧的 svn 提交),当我单击 g:link 显示detailController gsp 时,我收到以下错误:
groovy.lang.MissingPropertyException: No such property: facility for class: org.icf.Person
at org.bjc.icf.DetailController$_closure3.doCall(DetailController.groovy:33)
at org.bjc.icf.DetailController$_closure3.doCall(DetailController.groovy)
at java.lang.Thread.run(Thread.java:619)
我尝试查找可能的解决方案在线导致此错误,但我似乎找不到任何内容。有谁知道为什么我可能会突然在以前工作的代码上遇到 MissingPropertyExceptions (是的,我已经检查以确保该属性仍在类中)。
I've been getting a strange error that has had me hung up all morning. I have a Grails application with a Person class that looks like this:
class Person {
String id
Date lastUpdated
String note
String lastName
String firstName
String middleName
String facility
...
}
In my controller, I have a closure to obtain the model:
def personDetail = {
Person person = new Person()
...
List<Person> personSearchList = session.getAttribute("searchResults")
Person selectedSearchPerson = selectedSearchPersonList.find { it.id == selectedID }
person.firstName = selectedSearchPerson.firstName
person.lastName = selectedSearchPerson.lastName
person.middleName = selectedSearchPerson.middleName
person.facility = selectedSearchPerson.facility
...
return [person:person]
}
Now, this code was working fine yesterday. This morning however, without making any modifications (I have even tried reverting to older svn submissions) I am getting the following error when I click the g:link to display the detailController gsp:
groovy.lang.MissingPropertyException: No such property: facility for class: org.icf.Person
at org.bjc.icf.DetailController$_closure3.doCall(DetailController.groovy:33)
at org.bjc.icf.DetailController$_closure3.doCall(DetailController.groovy)
at java.lang.Thread.run(Thread.java:619)
I've tried looking up a solution to what might be causing this error online but I can't seem to find anything. Does anyone have any idea why I might all of a sudden be getting MissingPropertyExceptions on previously working code (and yes, I have checked to make sure the property is still in the class).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试运行
grails clean
- 有时增量编译会失败,因此强制完整编译通常会消除此类奇怪的问题。Try running
grails clean
- sometimes incremental compilation fails so forcing a full compile will often make weird issues like this go away.