<!-- 配置quartz -->
  <!-- 要调用的工作类 -->
    <bean id="quartzJob" class="com.alarm.action.AlarmAction">
  <property name="alarmService" ref="alarmService"></property>
<property name="ftpService" ref="ftpService"></property>
</bean>
    <!-- 定义调用对象和调用对象的方法 -->
    <bean id="jobtask"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<!-- 调用的类 -->
<property name="targetObject">
<ref bean="quartzJob" />
</property>
<!-- 调用类中的方法 -->
<property name="targetMethod">
<value>historyAlarmInfo</value>
</property>
</bean>
    <!-- 定义触发时间 -->
    <bean id="doTime"
class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<ref bean="jobtask" />
</property>
<!-- cron表达式 -->
<property name="cronExpression">
<value>0 57 */1 * * ?</value>
</property>
</bean>
   <!-- 总管理类如果将lazy-init='false'那么容器启动就会执行调度程序  -->
<bean id="startQuertz" lazy-init="false"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="doTime" />
</list>
</property>
</bean> 这是方法:
public String historyAlarmInfo() throws IOException{
System.err.println("任务执行中");
String saveNowAlarmInfo;
String exeInfo;
String downLoadFile;// 下载文件是否成功的状态
String analysisDate;// 分析.APX文件中的数据,放入数据库是否成功的状态
DATETIME = new dateFormat().formatAlarmDate();// 获取当前操作时间
List<TAlarminfotemporary> nowAlarmList;// 按当前操作时间查询告警信息
int currentNo = 1;
List<TFtpinfo> list = getAlarmService().findFtpInfo(currentNo);// 根据局号查询ftp信息
String uploadType = getFtpService().FtpUpload(list); // 上传查询告警脚本
if (uploadType.equals("FtpUploadOk")) {
exeInfo = getFtpService().exeAlarm(list); // 执行告警脚本
if (exeInfo.equals("true")) {
downLoadFile = getFtpService().FtpDownload(list);
if (downLoadFile.equals("FtpDownloadOk")) {
try {
analysisDate = this.updateAlarmInfo(list);
if (analysisDate.equals("ok")) {
nowAlarmList = getAlarmService().queryNowAlarmInfo(DATETIME);
saveNowAlarmInfo = getAlarmService()
.saveNowAlarmInfo(nowAlarmList);
if (saveNowAlarmInfo.equals("true")) {
System.err.println("告警信息保存成功");
System.err.println(DATETIME);
} else {
System.err.println("告警信息保存失败");
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
} else {
System.err.println("上传告警脚本文件失败");
}
return null;
}
报的错误:
org.springframework.scheduling.quartz.JobMethodInvocationFailedException: Invocation of method 'historyAlarmInfo' on target class [class com.alarm.action.AlarmAction] failed; nested exception is java.lang.NullPointerException
at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:269)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86)
at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
Caused by: java.lang.NullPointerException
at com.Ftp.dao.jdbc.FtpDaoJdbc.FtpUpload(FtpDaoJdbc.java:142)
at com.Ftp.service.impl.FtpServiceImpl.FtpUpload(FtpServiceImpl.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy1.FtpUpload(Unknown Source)
at com.alarm.action.AlarmAction.historyAlarmInfo(AlarmAction.java:1241)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:276)
at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:260)
... 3 more
[framework] 2012-01-10 17:35:00,604 - org.quartz.core.ErrorLogger -79192 [startQuertz_Worker-1] ERROR org.quartz.core.ErrorLogger  - Job (DEFAULT.jobtask threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: org.springframework.scheduling.quartz.JobMethodInvocationFailedException: Invocation of method 'historyAlarmInfo' on target class [class com.alarm.action.AlarmAction] failed; nested exception is java.lang.NullPointerException]
at org.quartz.core.JobRunShell.run(JobRunShell.java:227)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
Caused by: org.springframework.scheduling.quartz.JobMethodInvocationFailedException: Invocation of method 'historyAlarmInfo' on target class [class com.alarm.action.AlarmAction] failed; nested exception is java.lang.NullPointerException
at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:269)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86)
at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
... 1 more
Caused by: java.lang.NullPointerException
at com.Ftp.dao.jdbc.FtpDaoJdbc.FtpUpload(FtpDaoJdbc.java:142)
at com.Ftp.service.impl.FtpServiceImpl.FtpUpload(FtpServiceImpl.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy1.FtpUpload(Unknown Source)
at com.alarm.action.AlarmAction.historyAlarmInfo(AlarmAction.java:1241)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:276)
at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:260)
... 3 more

FtpDaoJdbc是:
public String FtpUpload(List<TFtpinfo> list) {
ActionContext ctx = ActionContext.getContext(); 
HttpServletRequest request = (HttpServletRequest)ctx.get(ServletActionContext.HTTP_REQUEST); 
HttpSession session = request.getSession();      
ServletContext  application  = session.getServletContext();    
String serverRealPath = application.getRealPath("/") ;//获取项目根路径
String ip = list.get(0).getIp();
String userName = list.get(0).getUsername();
String pwd = list.get(0).getPassword();
int port = list.get(0).getPort();
String servicePath = list.get(0).getServicePath();
String clientPath = serverRealPath+list.get(0).getLocalPath();
String fileName = list.get(0).getFileName();
try {
ftpclient = new FtpClient(ip, port);
ftpclient.login(userName, pwd);
System.err.println("登录结束");
try {
System.err.println("创建目录");
buildList((servicePath + fileName).substring(0, servicePath
.lastIndexOf("/")));
System.err.println("创建目录成功");
System.err.println("开始上传.....");
ftpclient.binary();

}