• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem to instainte inner class in org.quartz  RSS feed

 
benny rusli
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got the following error "org.quartz.SchedulerException: Problem instantiating class in quartz"
when I run this program, I want to schedule my db to backup every 18.00 . My question how to instainte the inner class ? with ClassLoader ? or have someone better idea ?

 
benny rusli
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry I forgot to put the CronTask class. This class will be called in JobDetail("","",CronTask.class)

 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which line triggers the error?
 
benny rusli
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is the line that produce error and I got the following error "org.quartz.SchedulerException: Problem instantiating class in quartz"


I want to test run it with
taststartenbutton.addActionListener(new TaskAction());
if I press the button the event should happen, but i got above error. Thanks for Helping
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I'm just guessing here (I have no idea what API we're talking about,) but it looks like the idea is you pass a Class object to the JobDetail constructor, and it then has to instantiate an instance of that class, right? Presumably, it does it by calling Class.newInstance() to invoke the no-argument constructor.

But an inner class doesn't have a no-argument constructor; the compiler adds an argument whose type is the outer class to every constructor of the inner class; this is how the "outer instance" gets initialized.

So I think you have two choices: you can turn CronTask into a static nested class, or you can turn it into a top-level class. In either case, the "jar()" and "zip()" methods of your outer class had better be static, since the CronTask won't be attached to an instance of the outer class.

Unless I'm missing something, this is not a very well-designed API; why doesn't the scheduler accept a job object rather than a job class?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!