Java EE Scheduler is not called

≯℡__Kan透↙ 提交于 2019-12-10 12:51:20

问题


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.


回答1:


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

@Schedule(minute = "*/5", hour="*")


来源:https://stackoverflow.com/questions/10246606/java-ee-scheduler-is-not-called

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!