users@glassfish.java.net

Creating a timer

From: <glassfish_at_javadesktop.org>
Date: Thu, 13 Nov 2008 09:39:23 PST

I have a stateless session bean that declares a timer service:

        @Resource
        private TimerService timerService;

I then wish to initialize the timer service after the construction is complete and all dependency injection has taken place:

        @PostConstruct
        public void postConstruct() {
                timerService.createTimer(CLEANUP_INTERVAL, null);
        }

However, I get:

java.lang.IllegalStateException: EJB Timer method calls cannot be called in this context

Is there any reason why I can't initialize a timer after the session bean has been created? It seems like a logical place to do so.
[Message sent by forum member 'kdeanddd' (kdeanddd)]

http://forums.java.net/jive/thread.jspa?messageID=316601