Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-4598

TimerHandle failed to retrieve timer after JBoss restart

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Obsolete
    • Icon: Major Major
    • No Release
    • 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

      { return conf.getTestCleanTimerHandle().getTimer(); }

      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...

          There are no Sub-Tasks for this issue.

              Unassigned Unassigned
              linoux Linoux Linoux (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: