[英]Quartz job not started - Tomcat server
i'm trying to upload a project that can run a job every X hour of the day to a web server. 我正在尝试将可以在一天中每X个小时运行一次作业的项目上载到Web服务器。
The problem is, when i'm running the project on my local (netbeans, apache 7) it's launched without problem and doing the job everytime i need, but if i deploy my war into a web server (Tomcat 8), it wont start. 问题是,当我在本地(netbeans,apache 7)上运行该项目时,它可以毫无问题地启动,并且每次都可以完成工作,但是如果我将战争部署到Web服务器(Tomcat 8)中,它将无法启动。
i've seen some examples and some are adding a quartz.properties and a web.xml under WEB-INF/class/ 我看过一些示例,有些在WEB-INF / class /下添加了quartz.properties和web.xml。
My project 我的项目
ProjectName
->Web pages
-->META-INF
-->WEB-INF
-->index.jsp
->Source Packages
-->job(package)
--->Job.java
-->main.java
main class
主班
public class main {
public static void main(String[] args) throws Exception {
JobDetail job = JobBuilder.newJob(HelloJob.class)
.withIdentity("dummyJobName", "group1").build();
Trigger trigger = TriggerBuilder
.newTrigger()
.withIdentity("dummyTriggerName", "group1")
.startNow()
.withSchedule(
CronScheduleBuilder.cronSchedule("0/15 * * * * ?")
)
.build();
//schedule it
Scheduler scheduler = new StdSchedulerFactory().getScheduler();
scheduler.start();
scheduler.scheduleJob(job, trigger);
}
} }
Job class
工作类别
public class HelloJob implements Job {
public void execute(JobExecutionContext context)
throws JobExecutionException {
System.out.println("Hello Quartz!");
}
} }
Thank you so much for your help! 非常感谢你的帮助!
Maybe this is not the best way to solve it but, i made it by creating a jsp that calls the method with the cron. 也许这不是解决它的最佳方法,但是我通过创建一个用cron调用该方法的jsp来实现了。
so, deploy --> call the jsp --> method --> cron. 因此,部署->调用jsp->方法-> cron。
The cron wasn't excecuted by anything before that. 在那之前,cron并没有被任何事情执行。
Thank you all! 谢谢你们!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.