-
Bug
-
Resolution: Obsolete
-
Major
-
JBossAS-4.0.5.GA
-
None
-
None
-
Windows XP / PostgreSQL
Creating a timer, store the associated TimerHandle in DB.
Restart JBoss server, try to get the Timer using the stored TimerHandle : javax.ejb.NoSuchObjectLocalException is thrown.
----------------------------------------------------------
//In a Stateless Session :
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void createTimer() throws OgpException {
TimerService ts = ctx.getTimerService();
Timer newTimer = ts.createTimer(getTimerStartDate(), DateUtil.MILLIS_IN_DAY, testAge);
conf.setTestCleanTimerHandle(newTimer.getHandle());
// Store conf in DB
}
private Timer getCurrentTimer(DbConfiguration conf) throws OgpException {
if (conf.getTestCleanTimerHandle() == null)
return null;
try
catch (NoSuchObjectLocalException e)
{ log.warn("Can't retrieve timer : it could be caused by the application redeployment", e); return null; }}
----------------------------------------------------------
Using this code, call to getCurrentTimer after calling createTimer works fine, but after a JBoss restart, call to getCurrentTimer ends with a NoSuchObjectLocalException :
javax.ejb.NoSuchObjectLocalException: Timer not available: [target=jboss.j2ee:service=EJB3,ear=ogp-app.ear,jar=ogp-ejb.jar,name=AdminCleanDbSessionBean]
at org.jboss.ejb.txtimer.TimerHandleImpl.getTimer(TimerHandleImpl.java:203)
at com.sts.ogp.ejb.admin.AdminCleanDbSessionBean.getCurrentTimer(AdminCleanDbSessionBean.java:157)
[...]
JBoss uses the PostgreSQL database to store the timers and all other stuff. I have noted that the timers.timerid field changed after restarting JBoss, that could explain why the Timer is not found by the TimerHandle...