|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
quartz pluggin Exception...
Hi,
I'm developing a grails service that executes a command. This service can be accessed using the hessian protocol. The task is scheduled using the Quartz plug-in. Here is the service code: --------------------------------------- > cat grails-app/services/Demo1Service.groovy import demoremoting.CronGlobusJobSubmit import quartzdemo.SimpleJobSubmit class Demo1Service implements demoremoting.CronGlobusJobSubmit { boolean transactional = false static expose = ['hessian'] def quartzScheduler def serviceMethod() { } String execute(String server, String jobmanager, String parameters, String when) { def job = new SimpleJobSubmit(scheduler: quartzScheduler) job.registerjob() } } ----------------------------- For modularity, I have implemented a jar file to deal with Job definition according to Quartz framework. Here is the code: -------------------------- > cat SimpleJobSubmit.groovy package quartzdemo import org.quartz.JobDetail import org.quartz.Scheduler import org.quartz.SimpleTrigger import org.joda.time.DateTime class SimpleJobSubmit { def scheduler = null void registerjob() { def sched sched = scheduler // We get the current time def currdatetime = new DateTime() // A new jobdetail is created from GlobusJobSubmitQuartzJob def jobDetail = new JobDetail("job${currdatetime}", "group", Echo.class) def trigger def startTime = new DateTime() startTime = startTime.plusMillis(2000) trigger = new SimpleTrigger("triggersimple${startTime}","group") trigger.setStartTime(startTime.toDate()) println "Scheduling a New Job" sched.scheduleJob(jobDetail,trigger) println "Job Scheduled!" } } ---------------------------------- The Echo groovy class is here: -------------------------------------- > cat Echo.groovy package quartzdemo import org.quartz.Job import org.quartz.JobExecutionContext import org.quartz.JobExecutionException class Echo implements Job { public void execute(JobExecutionContext context) throws JobExecutionException { println "I'm IN" } } -------------------------------- Now, I run the application using the traditional "grails prod run-app" and I use a hessian client for requesting the task execution(Below is the output). Note that the job is scheduled but something inside of Quartz launches the exception. What is wrong? Where is the 'name' variable defined? I have not defined any 'name' variable. How can I get the complete stack trace output? I appreciate your suggestion and comments. ------------------------------------- Server running. Browse to http://localhost:8080/launcherjobs Scheduling a New Job Job Scheduled! [13466] core.ErrorLogger An error occured instantiating job to be executed. job= 'group.job2008-07-08T14:17:05.755-04:00' org.quartz.SchedulerException: Job instantiation failed [See nested exception: java.lang.IllegalArgumentException: 'name' must not be null] at org.springframework.scheduling.quartz.AdaptableJobFactory.newJob(AdaptableJobFactory.java:41) at org.quartz.core.JobRunShell.initialize(JobRunShell.java:132) at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:358) Caused by: java.lang.IllegalArgumentException: 'name' must not be null at org.springframework.util.Assert.notNull(Assert.java:112) at org.springframework.beans.factory.BeanFactoryUtils.transformedBeanName(BeanFactoryUtils.java:71) at org.springframework.beans.factory.support.AbstractBeanFactory.transformedBeanName(AbstractBeanFactory.java:859) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:202) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:881) at org.codehaus.groovy.grails.plugins.quartz.GrailsJobFactory.createJobInstance(GrailsJobFactory.java:42) at org.springframework.scheduling.quartz.AdaptableJobFactory.newJob(AdaptableJobFactory.java:37) ... 2 more |
|
|
RE: quartz pluggin Exception...Hi John, The quartz scheduler that is registered by
the Quartz plugin has a specialized JobFactory that depends on the jobs being
registered statically by name in the spring container. The ‘name must
not be null’ error is coming from the JobFactory trying to find your job
in the spring container and discovering your dynamic job has no name (i.e. is
not found in the grails-app/jobs directory). The current edition of the quartz plug
does not readily support dynamically created jobs, although the next release of
it is supposed to support them directly. You can create dynamic jobs if you
gotta, but it’s tricky. Scheduling a dynamic trigger for a static job is
pretty easy though, so if it is possible for you to define your job in
grails-app/jobs then a dynamic trigger is the ticket. Its easy enough to pass per-job-run data
to the job via the trigger schedule mechanism, so often static jobs are ‘good
enough’. For example, if you have a class called grails-app/jobs/MyCoolJob
you can schedule a dynamic trigger for it like this: Trigger trigger = new CronTrigger(“My-T-ID”,
“My-T-Group”, cronExpression) trigger.setJobName(“MyCoolJob”) trigger.setJobGroup(“MyCoolJobGroup”)
// remember to specify this as the group name in jobs/MyCoolJob trigger.jobDataMap.myParamA = “something” trigger.jobDataMap.myParamB = “somethingElse” quartzScheduler.scheduleJob(trigger) note that the job data map can be set when
you schedule the trigger, and that data is passed to the job when the trigger
fires. Jay From: John Sanabria [mailto:john.sanabria@...] Hi, |
|
|
Re: quartz pluggin Exception...Hi Jay,
Thanks a lot... your comment help me to overcome my problem. Regards, Jay Guidos wrote: > > Hi John, > > The quartz scheduler that is registered by the Quartz plugin has a > specialized JobFactory that depends on the jobs being registered > statically by name in the spring container. The ‘name must not be > null’ error is coming from the JobFactory trying to find your job in > the spring container and discovering your dynamic job has no name > (i.e. is not found in the grails-app/jobs directory). > > The current edition of the quartz plug does not readily support > dynamically created jobs, although the next release of it is supposed > to support them directly. You can create dynamic jobs if you gotta, > but it’s tricky. Scheduling a dynamic trigger for a static job is > pretty easy though, so if it is possible for you to define your job in > grails-app/jobs then a dynamic trigger is the ticket. > > Its easy enough to pass per-job-run data to the job via the trigger > schedule mechanism, so often static jobs are ‘good enough’. For > example, if you have a class called grails-app/jobs/MyCoolJob you can > schedule a dynamic trigger for it like this: > > Trigger trigger = new CronTrigger(“My-T-ID”, “My-T-Group”, cronExpression) > > trigger.setJobName(“MyCoolJob”) > > trigger.setJobGroup(“MyCoolJobGroup”) // remember to specify this as > the group name in jobs/MyCoolJob > > trigger.jobDataMap.myParamA = “something” > > trigger.jobDataMap.myParamB = “somethingElse” > > quartzScheduler.scheduleJob(trigger) > > note that the job data map can be set when you schedule the trigger, > and that data is passed to the job when the trigger fires. > > Jay > > ------------------------------------------------------------------------ > > *From:* John Sanabria [mailto:john.sanabria@...] > *Sent:* Tuesday, July 08, 2008 12:40 PM > *To:* user@... > *Subject:* [grails-user] quartz pluggin Exception... > > Hi, > > I'm developing a grails service that executes a command. This service > can be accessed using the hessian protocol. The task is scheduled > using the Quartz plug-in. > > Here is the service code: > --------------------------------------- > > cat grails-app/services/Demo1Service.groovy > import demoremoting.CronGlobusJobSubmit > import quartzdemo.SimpleJobSubmit > > class Demo1Service > implements demoremoting.CronGlobusJobSubmit > { > boolean transactional = false > static expose = ['hessian'] > def quartzScheduler > > def serviceMethod() { > } > String execute(String server, String jobmanager, String parameters, > String when) { > def job = new SimpleJobSubmit(scheduler: quartzScheduler) > job.registerjob() > } > } > ----------------------------- > For modularity, I have implemented a jar file to deal with Job > definition according to Quartz framework. Here is the code: > -------------------------- > > cat SimpleJobSubmit.groovy > package quartzdemo > > import org.quartz.JobDetail > import org.quartz.Scheduler > import org.quartz.SimpleTrigger > import org.joda.time.DateTime > > class SimpleJobSubmit { > def scheduler = null > > void registerjob() { > def sched > sched = scheduler > > // We get the current time > def currdatetime = new DateTime() > // A new jobdetail is created from GlobusJobSubmitQuartzJob > def jobDetail = new JobDetail("job${currdatetime}", "group", > Echo.class) > > def trigger > def startTime = new DateTime() > startTime = startTime.plusMillis(2000) > trigger = new SimpleTrigger("triggersimple${startTime}","group") > trigger.setStartTime(startTime.toDate()) > * println "Scheduling a New Job"* > sched.scheduleJob(jobDetail,trigger) > * println "Job Scheduled!"* > } > } > ---------------------------------- > The Echo groovy class is here: > -------------------------------------- > > cat Echo.groovy > package quartzdemo > > import org.quartz.Job > import org.quartz.JobExecutionContext > import org.quartz.JobExecutionException > > class Echo implements Job { > public void execute(JobExecutionContext context) > throws JobExecutionException > { > println "I'm IN" > } > } > -------------------------------- > > Now, I run the application using the traditional "grails prod run-app" > and I use a hessian client for requesting the task execution(Below is > the output). Note that the job is scheduled but something inside of > Quartz launches the exception. > > What is wrong? Where is the 'name' variable defined? I have not > defined any 'name' variable. How can I get the complete stack trace > output? > > I appreciate your suggestion and comments. > ------------------------------------- > Server running. Browse to http://localhost:8080/launcherjobs > *Scheduling a New Job* > *Job Scheduled!* > [13466] core.ErrorLogger An error occured instantiating job to be > executed. job= 'group.job2008-07-08T14:17:05.755-04:00' > org.quartz.SchedulerException: Job instantiation failed [See nested > exception: java.lang.IllegalArgumentException: 'name' must not be null] > at > org.springframework.scheduling.quartz.AdaptableJobFactory.newJob(AdaptableJobFactory.java:41) > at org.quartz.core.JobRunShell.initialize(JobRunShell.java:132) > at > org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:358) > Caused by: java.lang.IllegalArgumentException: 'name' must not be null > at org.springframework.util.Assert.notNull(Assert.java:112) > at > org.springframework.beans.factory.BeanFactoryUtils.transformedBeanName(BeanFactoryUtils.java:71) > at > org.springframework.beans.factory.support.AbstractBeanFactory.transformedBeanName(AbstractBeanFactory.java:859) > at > org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:202) > at > org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) > at > org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) > at > org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:881) > at > org.codehaus.groovy.grails.plugins.quartz.GrailsJobFactory.createJobInstance(GrailsJobFactory.java:42) > at > org.springframework.scheduling.quartz.AdaptableJobFactory.newJob(AdaptableJobFactory.java:37) > ... 2 more > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Free Forum Powered by Nabble | Forum Help |