grails弹性搜索数据绑定错误

时间:2012-06-05 14:29:58

标签: data-binding grails

我正在使用grails 2.0.0 M1和弹性搜索插件0.18.7.1-SNAPSHOT。

我可以安装它,并且可以使用默认配置看到它运行正常。我还可以看到我的域对象正在创建并成功添加到我的DBBootStrap.groovy文件的索引中。

...然而

当尝试仅从Web层创建(不保存)域对象时(在Bootstap脚本成功运行之后),我收到以下错误:

def testco = new Company(name:"test");

Line | Method
->>  13 | registerCustomEditors in     org.grails.plugins.elasticsearch.conversion.CustomEditorRegistar
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    38 | test                  in com.tempism.company.CompanyController
|   886 | runTask . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
|   908 | run                   in     ''
^   619 | run . . . . . . . . . in java.lang.Thread

进一步调查显示堆栈跟踪与相关部分是......

java.lang.NullPointerException
    at groovy.lang.MetaClassImpl.addToAllMethodsIfPublic(MetaClassImpl.java:2975)
    at groovy.lang.MetaClassImpl.addProperties(MetaClassImpl.java:2954)
    at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:2918)
    at groovy.lang.ExpandoMetaClass.initialize(ExpandoMetaClass.java:468)
    at     org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:166)
    at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:182)
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:242)
    at org.codehaus.groovy.runtime.InvokerHelper.getMetaClass(InvokerHelper.java:751)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallConstructorSite(CallSiteArray.java:71)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:54)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
    at org.grails.plugins.elasticsearch.conversion.CustomEditorRegistar.registerCustomEditors(CustomEditorRegistar.groovy:13)
    at org.codehaus.groovy.grails.web.binding.GrailsDataBinder.registerCustomEditors(GrailsDataBinder.java:182)
    at org.codehaus.groovy.grails.web.binding.GrailsDataBinder.registerCustomEditors(GrailsDataBinder.java:263)
    at org.codehaus.groovy.grails.web.binding.GrailsDataBinder.createBinder(GrailsDataBinder.java:287)
    at org.codehaus.groovy.grails.web.binding.DataBindingUtils.createDataBinder(DataBindingUtils.java:238)
    at org.codehaus.groovy.grails.web.binding.DataBindingUtils.bindObjectToDomainInstance(DataBindingUtils.java:169)
    at org.codehaus.groovy.grails.web.binding.DataBindingUtils.bindObjectToDomainInstance(DataBindingUtils.java:112)
    at     org.codehaus.groovy.grails.plugins.web.api.ControllersDomainBindingApi.initialize(ControllersDomainBindingApi.java:57)
    at com.tempism.company.Company.<init>(Company.groovy)

相对较新的grails,我不知道如何创建域对象/ DataBinding可以在DBBootStrap上下文中工作,但不能在任何其他上下文中工作(服务/控制器。

非常感谢任何想法。

欢呼声。

... UPDATE

//works
def co =  new Company();
co.name = "hello"
co.save();

//doesn't work
new Company(name:"hello2").save();

1 个答案:

答案 0 :(得分:0)

通过更新到grails 2.0.1

解决