tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Russo <>
Subject Singleton + Timer service
Date Mon, 08 Feb 2010 17:51:30 GMT
Good afternoon everyone,

I have a question about the ejb timer services with the new singleton
beans.  What I want to do is create a timer service that starts on
openejb startup, so I thought it would be perfect to use the singleton
bean for this purpose.  However, when I try to create the timer in the
singleton post-construct method, I get this error:

java.lang.IllegalStateException: TimerService method not permitted for
current operation POST_CONSTRUCT

Is this a bug, an incomplete implementation, or by design?  I suppose I
can work around by using a servlet context listener, but I figured
singleton beans would be cleaner.

Here is my singleton class:

public class TimerServiceTestBean implements TimerServiceTestLocal {
    private static Logger _log =
    private volatile static Timer _timer;
    private TimerService _timerService;

    public void onStartup() {
        _timer = _timerService.createTimer(60000, 60000, null);"Starting TimerServiceTestBean timer.");

    public void onShutdown() {
        _timer.cancel();"Shutting down TimerServiceTestBean timer.");

    public void onTimeout(Timer timer) {"TimeServiceTestBean has just received a timeout
notice at "
                + (new Date()).toString());

Jason Russo

Application Developer

Genscape– See the Energy

445 E. Market St, Suite 200

Louisville, KY 40202

Tel: 502-583-2091

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message