I created below class to check the scheduling of ManagedScheduledExecutorService class. I am printing message in console.
public class URLHealthProcessor  implements Runnable{
          
    @Override
    public void run() throws Exception {
        
        System.out.println("inside the run method");
}      
 }
I created below class to call this class.
public class URLHealthResource {
    
    @Resource(lookup="java:comp/DefaultManagedScheduledExecutorService")
    private ManagedScheduledExecutorService scheduledExecutorService;
    
    
    public String checkHealthOfApp()
    {
     ZonedDateTime now = ZonedDateTime.now(ZoneId.of("America/Los_Angeles"));
        ZonedDateTime nextRun = now.withHour(2).withMinute(36).withSecond(0);
        if(now.compareTo(nextRun) > 0)
            nextRun = nextRun.plusMinutes(5);
        Duration duration = Duration.between(now, nextRun);
        long initalDelay = duration.getSeconds();
        
        System.out.println("I am inside checkHealthOfApp method");
        scheduledExecutorService.scheduleAtFixedRate(new URLHealthProcessor(),
            initalDelay,
            TimeUnit.DAYS.toSeconds(1),
            TimeUnit.SECONDS);   
}
}
Actually at a schedule time it is not running.
Do I need to add this class in some container or somewhere else? After creating above classes I restarted webserver but scheduler is not picking the job. basically I want to know how checkHealthOfApp() method will be called in web application.
When I created same taks using ScheduleExecutorService(Java SE) and I ran main method after that job was picking automatically at schedule time.
Do i need to trigger above job somehow manually? I need to create web application so I am using ManagedScheduledExecutorService.
I am new to java. As for as I know I dont need to create main in web application. container loads classes automatically. but here it is not calling method at its time.
