0

i'm trying to upload a project that can run a job every X hour of the day to a web server.

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.

i've seen some examples and some are adding a quartz.properties and a web.xml under WEB-INF/class/

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!

1 Answers1

0

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.

so, deploy --> call the jsp --> method --> cron.

The cron wasn't excecuted by anything before that.

Thank you all!