Reputation: 967
How to resolve groovy.lang.MissingMethodException: No signature of method: methodMissing() is applicable for argument types: () values: []?
In my project I have two plugins and I am getting this exception at start-up for one of the plugins (All the functionality of this plugin is fine)
I've got the exception on this line for 'findAllByStatus'
def newItemList = Item.findAllByStatus(ItemStatus.NEW)
I have imported Item.groovy in current service class, also the service class is being created at start-up when quartz is starting. I'm not sure if it is related to quartz or not.
Item is a domain class.
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;
}
}
The stack trace:
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
ItemStatus is:
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
}
}
}
Upvotes: 1
Views: 3002
Reputation: 436
What I've done to solve this problem is to postpone the start of the Quartz Scheduler. As Ima said, there is a kind of race condition that makes GORM not available until the Grails app has completely started. If you try to use it before, you get a MissingMethodException
.
My solution involved disabling the Quartz Scheduler autoStartup
(see https://github.com/9ci/grails-quartz2/blob/07ecde5baa59e20f99c05302c61137617c08fc81/src/groovy/grails/plugin/quartz2/QuartzFactoryBean.groovy#L61) and to start()
it in the Bootstrap.groovy
after all the initialization was done.
This is the config to prevent autoStartup:
grails {
plugin {
quartz2 {
autoStartup = false
}
}
}
Using this way you don't have to give up using GORM, as Ima suggested.
Upvotes: 2
Reputation: 967
Finally, I found the solution.
At the start-up, quartz loads service class but it couldn't execute GORM commands at this point. Then I changed it to the native sql select * from xcomms_item where status = 0
. Now it works fine.
Upvotes: 1