0 Replies Latest reply on Feb 27, 2005 10:16 AM by inglor

    Problems in Timer persistence in JBoss 4.0.0 / Mysql 4.1

    inglor

      Hello.
      I have the following problem using Timers in my J2EE application. I have 3 Session Beans which implement TimedObject. At the deployment of the app, I start the timers (which guard some external events, like "picking up a new mail" etc. - not important here) and at undeployment of the app, I stop the timers. They have moderate intervals, like 120 seconds.
      However, sometimes (and I cannot see the logic of when this happens, but it is sort of "once in 5 undeployments"), the corresponding entries in MySQL table TIMERS do not get deleted; or, more precisely, some of the three entries does not. Then, after redeployment of the app, the following exception appears:

      Cannot create txtimer
      java.lang.IllegalStateException: Unable to persist timer
      at org.jboss.ejb.txtimer.DatabasePersistencePolicy.insertTimer(DatabasePersistencePolicy.java:137)
      ...
      Caused by: java.sql.SQLException: Duplicate key or integrity constraint violation message from server: "Duplicate entry '3' for key 1"

      and the corresponding timer does not run anymore. To repair this, I must manually delete the whole contents of table TIMERS.

      Similar problem happens when I kill jboss with -9 option, but that is understandable. I do not understand, why TIMERS entries sometimes do not get deleted at regular undeployment. Is it possible that it would be a bug in JBoss? Or is it my bug that I use 3 TimedObjects while I should use one only, which branching in timeoutEjb() method?

      I do not like this, since I need all timers up and running, and I am afraid of the possibility that JBoss gets restarted automatically sometimes at 2 AM and will encounter this error, therefore running my app without one or more of the timers.

      Thank you for any reaction.