Skip to main content

Single Interval EJB 3.0 Timer in Stateless Session Bean does not invoke @Timeout callback method


Technote (troubleshooting)


Problem(Abstract)

While using IBM Rational Application Developer for WebSphere Software v7.5.2 with WebSphere Application Server v7.0.0.1, a Single Interval EJB 3.0 Timer in a Local Interface Stateless Session Bean does not invoke @Timeout callback method when it expires.

Cause

Unknown.

Defect APAR PK73068 is likely a component related to this issue.

Environment

// Example of a simple stateless session ejb 3.0 with Single Interval Timer

package ejbtm;

import java.util.Date;
import java.util.logging.Logger;

import javax.annotation.Resource;
import javax.ejb.Stateless;
import javax.ejb.Timeout;
import javax.ejb.Timer;
import javax.ejb.TimerService;

/**
* Session Bean implementation class MyTimerEJB
*/
@Stateless
public class MyTimerEJB implements MyTimer
{
/**
* Default constructor.
*/
public MyTimerEJB() {
// constructor stub
}
private static final Logger log = Logger.getLogger(MyTimerEJB.class.getName());

private static final String TM_NAME = "MyTestTimer";

@Resource
TimerService timerService;

@Timeout
public void myTimeout(Timer timer)
{
// Why is it not called when MyTestTimer expires?
System.out.println("Timeout myTimeout() called");
System.out.println("... called at: " + new Date(System.currentTimeMillis()));

log.info("Timer fired: timer=" + timer.getInfo());
}

public void startTimer()
{
log.info("Start timer");
log.info("...but first Stop any timers");
stopTimer();
// Create time expiring in 10 sec
long duration = 1000 * 10;

Timer timer = timerService.createTimer(duration, TM_NAME);
System.out.println("Created Timer at : " + new Date(System.currentTimeMillis()));
log.info("Timer created: timer=" + timer.getInfo());
log.info("TimeRemaining=" + timer.getTimeRemaining());
log.info("Next timeout=" + timer.getNextTimeout());


}

public void stopTimer()
{
log.info("Stop timer");

for (Object tm : timerService.getTimers()) {
Timer timer = (Timer)tm;

log.info("Cancel timer: timer=" + timer.getInfo());
timer.cancel();
}
}

public void printTimer()
{
log.info("Print timer");

for (Object tm : timerService.getTimers()) {
Timer timer = (Timer)tm;

log.info("timer=" + timer.getInfo());
}
}
}


Resolving the problem

Upgrade to WebSphere Application Server v7.0.0.3 for Rational Application Developer v7.5.x using the Installation Manager:Updater, resolved this problem.

Note: This Timer related APAR fix in WebSphere Application Server 7.0.0.3 for single interval timers, along with other non-APAR defect fixes may have contributed to the resolution. If upgrading to the latest available WebSphere Application Server 7.0.0.x FixPack does not help, you may have a new issue and
IBM Support for WebSphere Application Server should be contacted.


Rate this page:

(0 users)Average rating

Copyright and trademark information

IBM, the IBM logo and ibm.com are trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at www.ibm.com/legal/copytrade.shtml.

Rate this page:


(0 users)Average rating

Add comments

Document information

Rational Application Developer for WebSphere Software

EJB Development


Software version:
7.5, 7.5.1, 7.5.2


Operating system(s):
Linux, Windows


Reference #:
1388449


Modified date:
2009-05-27

Translate my page

Content navigation