北纬30度水域
2016-01-07 03:39
采纳率: 50%
浏览 3.6k

Spring 定时任务 在执行方法时报空指针

定时任务的xml:


com.boco.auto.AutoIPV6BusinessAlarmStatisticsReport







0 30 3 * * ?


Spring注入:
class="com.boco.web.struts.action.report.ReportCommonActionPipeRes"
parent="baseAction">





















<!-- add liuhuipeng -->





class="com.boco.alarm.service.impl.VendorFaultReportServiceImpl">













定时任务:
public class AutoAlarmStatisticsReport implements Job{
static Logger logger = Logger.getLogger(AutoAlarmStatisticsReport.class) ;
private ReportCommonActionPipeRes pipeResAction;

@Override
public void execute(JobExecutionContext arg0) throws JobExecutionException {
    logger.info("+++进入定时任务。+++");
    generateReport();
}
public void generateReport(){
    logger.info("modelName=AlarmStatistics");
    pipeResAction = (ReportCommonActionPipeRes)StartupApp.getInstance().
    getAppContext().getBean("reportpiperesource");
    String modelName = "IPV6BusinessAlarmStatistics";
    Date date = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    String today = sdf.format(date);
    this.pipeResAction.insertBusinessNEStatistics(modelName);
    //insertBusinessNEStatistics(modelName);
}

}
调用此方法:
public boolean insertBusinessNEStatistics(String modelName){
boolean isOk = false;
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String createDate = sdf.format(date);
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date datestart = new Date();

String startDateString="";
startDateString= sdf1.format(datestart);
List Allist = new ArrayList();
String informixSql = statementManagementBean.getStatementByName(modelName.trim());
Map parameterMap = new HashMap();

    if((null == informixSql)||informixSql.equalsIgnoreCase("no such table")){
        return isOk;
    }else{
        String[] sql_Array = informixSql.split(";");
        List<Map> dataList = new ArrayList<Map>();
        for(String sql : sql_Array){
            if(sql != null && sql.trim().length() > 0){
                if(modelName.equalsIgnoreCase("AlarmStatistics")){
                    String procName = "{call pro_alarm_trans_counteveryday()}";
                    boolean isInsertflag= false;
                    //测试:
                    isInsertflag = true;
                //  try {
                //      isInsertflag = vendorfaultService.insertIPV6AlarmCount(procName);
                //      logger.info("++获得告警标识:++"+isInsertflag);
                //  } catch (Exception e) {
                        // TODO: handle exception
                //      logger.error("error 错误的信息", e);
                //  }
                    if(isInsertflag == true){
                        try{
                            dataList = vendorfaultService.queyAlarm(parameterMap, sql.trim(), false);
                        }catch(Throwable t){
                            logger.error("error 错误的信息", t);
                        }
                    }else{
                        return isInsertflag;
                    }
                }else{
                    //dataList = reportCommonDao.commonQuery(sql.trim(), parameterMap);
                    dataList = reportCommonDao.commonQuery(sql.trim(), parameterMap);
                }

            }
        }

        isOk = true;
    }
    return isOk;    
}
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • 飞火流星02027 2016-01-07 06:37

    请把异常全部粘贴出来,这样别人才更容易帮到你!

    评论
    解决 无用
    打赏 举报
  • 北纬30度水域 2016-01-08 06:37

    自己找到了,原来这里面是双配置。自己就注入了一个。

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题