EJB @Timeout method is called twice after hot re-deploy in JBoss EAP 6

Solution Verified - Updated -

Issue

  • We have the following simple app: one @Singleton bean with @Timeout method and one servlet which starts timer. After first deploy we see that method is called once in 2 seconds - which is expected. Then after hot re-deploy we see that method is called twice within 2 seconds. After a few redeploys method is called multiple times during the same 2 seconds. Restarting the server doesn't help. See the code below:

EJB Timer code:

import javax.ejb.*;

@Remote(TimerRemote.class)
@Singleton
public class TimerBean implements TimerRemote {
  @Resource
  private SessionContext context;

  public void startTimer() {
    context.getTimerService().createTimer(2000,2000,null);    
  }

  @Timeout
  public void timeoutCallback(javax.ejb.Timer timer) {
    System.out.println("timeoutCallback is called: " + timer);
  }
}
public interface Timer {
    public void startTimer();
}

Servlet code that calls the EJB to start the timer:

public class TestServlet extends HttpServlet {
  @EJB 
  private Timer timer;

  public void init() {
    System.out.println("init timer");
    timer.startTimer();
  }
}

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content