如何解决groovy.lang.MissingMethodException?
如何解析groovy.lang.MissingMethodException:methodMissing()的签名不适用于参数类型:()值:[] 在我的项目中,我有两个插件,其中一个插件在启动时出现了这个异常(这个插件的所有功能都很好) 我在这一行有“findAllByStatus”的例外如何解决groovy.lang.MissingMethodException?,groovy,grails-2.0,grails-plugin,grails-domain-class,quartz-core,Groovy,Grails 2.0,Grails Plugin,Grails Domain Class,Quartz Core,如何解析groovy.lang.MissingMethodException:methodMissing()的签名不适用于参数类型:()值:[] 在我的项目中,我有两个插件,其中一个插件在启动时出现了这个异常(这个插件的所有功能都很好) 我在这一行有“findAllByStatus”的例外 def newItemList = Item.findAllByStatus(ItemStatus.NEW) 我已经在当前服务类中导入了Item.groovy,并且在启动quartz时正在创建服务类。我不确
def newItemList = Item.findAllByStatus(ItemStatus.NEW)
我已经在当前服务类中导入了Item.groovy,并且在启动quartz时正在创建服务类。我不确定它是否与石英有关
项是一个域类
class Item implements Serializable {
ItemStatus status
Date dateCreated
Date lastUpdated
def updateLastUpdated(){
lastUpdated = new Date()
}
static hasMany = [itemProperties : ItemProperty]
static mapping = {
table 'xcomms_item'
datasource 'xcomms'
}
static constraints = {
batch nullable:true
}
@Override
public int hashCode() {
return 13 * id.hashCode();
}
@Override
public boolean equals(Object obj) {
if ((obj != null) && (obj instanceof Item) && (((Item)obj).id.equals(this.id))) {
return true;
}
return false;
}
}
堆栈跟踪:
groovy.lang.MissingMethodException: No signature of method: xcomms.Item.methodMissing() is applicable for argument types: () values: []
at xcomms.CommunicationBatchProcessService.communicationProcesss(CommunicationBatchProcessService.groovy:53)
at xcomms.AutomatedCommunicationJob.execute(AutomatedCommunicationJob.groovy:16)
at grails.plugin.quartz2.GrailsArtefactJob.execute(GrailsArtefactJob.java:59)
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557)
2013-11-14 14:20:00,112 [QuartzJobCluster_Worker-2] ERROR quartz2.JobErrorLoggerListener - Exception thrown in job:xcomms.AutomatedCommunicationJob
org.quartz.JobExecutionException: xcomms.communication.exception.CommunicationProcessException: Error in processing communication batch [See nested exception: xcomms.communication.exception.CommunicationProcessException: Error in processing communication batch]
at grails.plugin.quartz2.GrailsArtefactJob.execute(GrailsArtefactJob.java:66)
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557)
Caused by: xcomms.communication.exception.CommunicationProcessException: Error in processing communication batch
at xcomms.AutomatedCommunicationJob.execute(AutomatedCommunicationJob.groovy:19)
at grails.plugin.quartz2.GrailsArtefactJob.execute(GrailsArtefactJob.java:59)
... 2 more
Caused by: groovy.lang.MissingMethodException: No signature of method: xcomms.Item.methodMissing() is applicable for argument types: () values: []
at xcomms.CommunicationBatchProcessService.communicationProcesss(CommunicationBatchProcessService.groovy:53)
at xcomms.AutomatedCommunicationJob.execute(AutomatedCommunicationJob.groovy:16)
... 3 more
项目状态为:
public enum ItemStatus {
NEW(0,"New"),BATCHED(1,"Batched"),SENT(2,"Sent")
final int id
final String name
private ItemStatus(int id, String name) { this.id = id; this.name = name;}
static ItemStatus getById(int i){
for( entry in ItemStatus.values() ){
if(entry.id == i)
return entry
}
}
}
最后,我找到了解决办法。
在启动时,quartz加载服务类,但此时无法执行GORM命令。然后我将其更改为本机sql
select*fromXcomms\u项,其中status=0
。现在它工作正常。我为解决这个问题所做的是推迟启动Quartz调度程序。正如Ima所说,有一种竞争条件使得GORM在Grails应用程序完全启动之前不可用。如果您以前尝试使用它,您会得到一个MissingMethodException
我的解决方案包括禁用Quartz调度程序autoStartup
(请参阅),并在所有初始化完成后在Bootstrap.groovy
中启动它
这是防止自动启动的配置:
grails {
plugin {
quartz2 {
autoStartup = false
}
}
}
使用这种方式,您不必像Ima建议的那样放弃使用GORM。您在哪里调用
Item.findAllByStatus
以及完整的堆栈跟踪?(或者从顶部开始至少10行左右)@tim_yates我在一个名为“xcomms.CommunicationBatchProcessService”的服务类中调用了“Item.findAllByStatus”是ItemStatus.NEW类型的ItemStatus吗?当您说,Item.findAllByStatus
时,它需要ItemStatus类型的东西。是否可以包含ItemStatus的代码?ItemStatus.NEW是ItemStatus的一种类型。