4

我在实现 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.

所以我收到了这个错误,我不确定如何解决这个问题..有什么帮助吗??

4

1 回答 1

2

看起来您的作业类没有默认构造函数。要使用 TriggerBuilder 安排作业,您需要 Job 类具有默认构造函数。

于 2014-03-20T20:07:12.183 回答