Java EE Scheduler is not called
Asked Answered
B

1

10

I'm running my application inside Glassfish. I tried to create a job, which will be executed every 5 minutes like this:

@Startup
@Singleton
@LocalBean
public class TempFolderCleaner {
    private final static Logger LOGGER = LoggerFactory.getLogger(TempFolderCleaner.class);

    @EJB
    private ReportStatusDao reporStatusDao;

    @Schedule(minute = "*/5")
    public void removeOldReports() {
        LOGGER.debug("start removeOldReports()");
    }
}

However, it is never called. I tried to see a message from the logger and to set a debug point but it won't be called. I used this documentation for the syntax: http://download.oracle.com/javaee/6/tutorial/doc/bnboy.html

I also tried to specify the minutes exactly. Unfortunately without success either.

Bog answered 20/4, 2012 at 12:51 Comment(1)
Note that you don't need the @LocalBean annotation here.Osburn
S
17

I think "hour" defaults to 0 (midnight), so you might need to specify it as:

@Schedule(minute = "*/5", hour="*")
Scherzando answered 20/4, 2012 at 13:7 Comment(2)
you're absolutely right. Thanks a lot! Second, hour and minute have the default value "0" instead of "*" like the other properties.Bog
It solved me, but this is weird since from the doc i inderstood that minute = "/5" should explicitly set hour to "". But hey ....Waft

© 2022 - 2024 — McMap. All rights reserved.