Quartz 调度程序未在战争中运行
我在 gwt Web 应用程序中使用quartz 调度程序。我的应用程序结构如下所示。
我有两个项目。一个是 gwt Web 应用程序客户端项目(用于 ui 部分)&另一个是用于服务器端调用的java项目。(用于数据库交互)。在客户端项目中,我放置了一个服务器项目作为参考。运行时,我从客户端创建一个war,并将服务器项目的jar添加到war文件夹中。
现在我在服务器端使用调度程序来自动完成某些任务。在本地运行它(没有战争)调度程序正常工作。
但是在 jboss 服务器上运行 war 时,调度程序没有运行。
我所有与调度程序相关的代码和 Quartz.jar 都在服务器端。客户端项目中没有任何 Quartz 的引用。这是问题吗???
这是我的调度程序代码
public class QuartzJob implements Job {
public void execute(JobExecutionContext jobExecutionContext)
throws JobExecutionException {
JobDataMap map = jobExecutionContext.getJobDetail().getJobDataMap();
ActivityTransactionSettingsMap map2 = (ActivityTransactionSettingsMap) map
.get("task");
if (map2.getAutoCompleteDate() != null) {
WorkFlowFacade facade = new WorkFlowFacade();
facade.completeAutoCompleteTask(map2);
Scheduler scheduler=(Scheduler) map.get("scheduler");
try {
scheduler.shutdown();
} catch (SchedulerException e) {
e.printStackTrace();
}
}
}
}
Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
scheduler.start();
JobDataMap map2 = new JobDataMap();
map2.put("task", actsMap);
map2.put("scheduler", scheduler);
JobDetail job = newJob(QuartzJob.class).withIdentity("job"+String.valueOf(actsMap.getId()))
.usingJobData(map2).build();
Trigger trigger = newTrigger().withIdentity("trigger"+String.valueOf(actsMap.getId()))
.startAt(actsMap.getAutoCompleteDate()).build();
scheduler.scheduleJob(job, trigger);
或者我是否需要仅在客户端转移我的调度程序相关项目? 我不知道如何解决这个问题。 请帮帮我
I am using quartz scheduler in gwt web application.My application structure is like below.
I have two project.One is gwt web application client project(for ui part) & other is java project for server side call.(for database interaction).In client project I put a server project for reference.While running I create a war from client and add a jar of server project to war folder.
Now I used scheduler at server side for some task to auto complete.While running it locally (with out war) scheduler working properly.
But while running war at jboss server scheduler is not running.
My all scheduler related code and Quartz.jar is at server side.There is no any reference of Quartz in client side project.is this the problem???
Here is my code for scheduler
public class QuartzJob implements Job {
public void execute(JobExecutionContext jobExecutionContext)
throws JobExecutionException {
JobDataMap map = jobExecutionContext.getJobDetail().getJobDataMap();
ActivityTransactionSettingsMap map2 = (ActivityTransactionSettingsMap) map
.get("task");
if (map2.getAutoCompleteDate() != null) {
WorkFlowFacade facade = new WorkFlowFacade();
facade.completeAutoCompleteTask(map2);
Scheduler scheduler=(Scheduler) map.get("scheduler");
try {
scheduler.shutdown();
} catch (SchedulerException e) {
e.printStackTrace();
}
}
}
}
Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
scheduler.start();
JobDataMap map2 = new JobDataMap();
map2.put("task", actsMap);
map2.put("scheduler", scheduler);
JobDetail job = newJob(QuartzJob.class).withIdentity("job"+String.valueOf(actsMap.getId()))
.usingJobData(map2).build();
Trigger trigger = newTrigger().withIdentity("trigger"+String.valueOf(actsMap.getId()))
.startAt(actsMap.getAutoCompleteDate()).build();
scheduler.scheduleJob(job, trigger);
Or do I need to shift my scheduler related project at client side only??
I am not getting how to solve this.
Please help me out
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为了让调度程序运行,应该有一些东西来启动它。我不确定这个过程是如何发生的,但您可以在 servlet
和启动时的 web.xml 加载调度程序中编写此调度程序。这对我有用。
For the scheduler to run , there should be something to kick start it . I am not sure how the process is happening but you could write this scheduler in a servlet
and in your web.xml load sceduler on startup. This works for me.
在这种情况下我使用了线程。
如下
所示,在本地计算机中它工作正常。但对于 jboss 服务器它不工作。
I used thread in this case.
}
As below and in local machine it is working fine.but for jboss server it is not working.
我使用了 AutoCompleteTaskThread 类的实例并调用了它的 start 方法。
在这里,我为任何我想要启动新线程的新任务启动了一个线程。
I used an instance of AutoCompleteTaskThread class and called start method on this.
Here for I started a thread for any new task for which I want to start new thread.