I installed Quartz Plugin in a grails project but when I compile , It gives me the following error.
Error loading plugin manager: startup failed:
C:\Users\X\.grails\1.3.7\projects\Val\plugins\quartz-0.4.2\QuartzGrailsPlugin.groovy: 116: You cannot create an instance from the abstract interface 'org.quartz.CronTrigger'.
@ line 116, column 35.
Trigger trigger = new CronTrigger(generateTriggerName(), GTCP.DEFAULT_TRIGGERS_GROUP, jobName, jobGroup, cronExpression)
^
C:\Users\X\.grails\1.3.7\projects\Val\plugins\quartz-0.4.2\QuartzGrailsPlugin.groovy: 122: You cannot create an instance from the abstract interface 'org.quartz.SimpleTrigger'.
@ line 122, column 35.
Trigger trigger = new SimpleTrigger(generateTriggerName(), GTCP.DEFAULT_TRIGGERS_GROUP, jobName, jobGroup, new Date(), null, repeatCount, interval)
^
C:\Users\X\.grails\1.3.7\projects\Val\plugins\quartz-0.4.2\QuartzGrailsPlugin.groovy: 128: You cannot create an instance from the abstract interface 'org.quartz.SimpleTrigger'.
@ line 128, column 35.
Trigger trigger = new SimpleTrigger(generateTriggerName(), GTCP.DEFAULT_TRIGGERS_GROUP, jobName, jobGroup, scheduleDate, null, 0, 0)
^
C:\Users\X\.grails\1.3.7\projects\Val\plugins\quartz-0.4.2\QuartzGrailsPlugin.groovy: 133: You cannot create an instance from the abstract interface 'org.quartz.SimpleTrigger'.
@ line 133, column 35.
Trigger trigger = new SimpleTrigger(generateTriggerName(), GTCP.DEFAULT_TRIGGERS_GROUP, jobName, jobGroup, scheduleDate, null, 0, 0)
^
4 errors
and this is what I am trying to achieve…
class MyJob {
static triggers = {
cron name: 'myTrigger', cronExpression: "0 0 6 * * ?"
}
def group = "MyGroup"
def execute(){
print "Job run!"
}
}
Note: Plugin version is 0.4.2
I really can’t reproduce it. I created a new project and installed the plugin and it runs perfectly. You’re not trying to create an instance of the MyJob class, right? Basically, once installed, this class (the job) is ready to run. It will get triggered depending on the setting on the cronExpression.
Here are the steps I took to test your scenario:
1) Create grails app:
2) install plugin:
3) create a new job:
4) edit the MyJob class:
5) Run the application:
=> You should see the text “Job run” printed out every second since the cronExpression would trigger it for every second. Inside execute() is where you would put the code which you want to be executed by your cron job. I suggest creating a service and putting the code to run in the service and call it inside the execute() method.