我将调度程序放在实现Job接口的类上,当我在代码中创建类的对象并运行应用程序时,它给出了如下错误..有什么帮助?
public class Chart extends ApplicationFrame implements Job{
//Main class
String imagepath=IASGlobal.APPLICATION_PATH;
XYDataset dataset= null;
public Chart(final String title) {
super(title);
final XYDataset dataset = createDataset();
final JFreeChart chart = createChart(dataset);
try{
final ChartRenderingInfo info = new ChartRenderingInfo
(new StandardEntityCollection());
final File file1 = new File("/home/iasf/workspace/iasf/WebContent/images/chart89.png");
ChartUtilities.saveChartAsPNG(file1, chart, 1200, 800, info);
}catch(Exception e){}
******************
then some code
******************
JFreeChart createChart(final XYDataset dataset) {
//somr code here
}
private XYDataset createDataset(){
//some code here
}
public void execute(JobExecutionContext arg0) throws JobExecutionException {
// TODO Auto-generated method stub
final Chart demo = new Chart("Time Series Demo 8");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
System.out.println("im done with 10 mins..");
}
}
[ERROR] 04 Oct 04:56:00.046 PM DefaultQuartzScheduler_QuartzSchedulerThread [org.quartz.core.ErrorLogger]
An error occured instantiating job to be executed. job= 'ChrtScheduleUp.ChartScheduleJob'
org.quartz.SchedulerException: Problem instantiating class 'modules.images.Chart' [See nested exception: java.lang.InstantiationException: modules.images.Chart]
at org.quartz.simpl.SimpleJobFactory.newJob(SimpleJobFactory.java:57)
at org.quartz.core.JobRunShell.initialize(JobRunShell.java:132)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:358)
Caused by: java.lang.InstantiationException: modules.images.Chart
at java.lang.Class.newInstance0(Class.java:357)
at java.lang.Class.newInstance(Class.java:325)
at org.quartz.simpl.SimpleJobFactory.newJob(SimpleJobFactory.java:55)
... 2 more
[INFO] 04 Oct 04:56:00.050 PM DefaultQuartzScheduler_QuartzSchedulerThread [org.quartz.simpl.RAMJobStore]
All triggers of Job ChrtScheduleUp.ChartScheduleJob set to ERROR state.
所以我得到这个错误,我不知道如何解决这个问题.
最佳答案 看起来您的工作类没有默认构造函数.
要使用TriggerBuilder安排作业,您需要Job类具有默认构造函数.