/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.appriss.test.timer; import java.util.Date; import java.util.logging.Logger; import javax.annotation.PostConstruct; import javax.annotation.Resource; import javax.ejb.LocalBean; import javax.ejb.SessionContext; import javax.ejb.Singleton; import javax.ejb.Startup; import javax.ejb.Timeout; import javax.ejb.Timer; @Startup @Singleton @LocalBean public class TimerSingletonBean { private static final Logger logger = Logger.getLogger(TimerSingletonBean.class.getName()); @Resource private SessionContext ctx; // @PostConstruct NOTE: This line is commented out and the problem still happens even though a timer is never initialized because init never gets called private void init() { logger.info("Initializing timer"); ctx.getTimerService().createTimer(new Date(System.currentTimeMillis() + 120000), "TestTimer"); } @Timeout private void timerFired(Timer timer) { if(timer.getInfo().equals("TestTimer")) { logger.info("Timer fired"); } } }