1

目前我已经在 jboss5.1.1 中添加了quartz-1.8.6 和quartz-jboss-1.8.6 jar 和quartz-service.xml 文件,并且我已经在EAR 应用程序中添加了quartz1.8.6 相关的jar 文件并且我已经返回代码如下:

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
InitialContext ctx = new InitialContext();
SchedulerFactory sf = new StdSchedulerFactory();
Scheduler sched = sf.getScheduler();
JobDetail job = new JobDetail("job1", "group1", SimpleJob.class);
CronTrigger trigger = new CronTrigger("trigger1", "group1", "job1", "group1", "0/5 * * * * ?");
sched.addJob(job, true);
Date ft = sched.scheduleJob(trigger);
try
{
 Thread.activeCount();
catch (Exception e)
 {
}
sched.start();
} 
catch (Exception exc){ 
exc.printStackTrace();
}
.....
} 

但是一旦我登录链接,这段代码就会成功运行......但是一旦服务器启动,我需要它来运行 crontask

4

0 回答 0