2 Replies Latest reply on Jan 19, 2006 5:57 PM by Dimitris Andreadis

    Cancelled Persistent EJB Timers not deleted from DB?

    Vickj Fisherboss Newbie

      Hi All,

      I'm using Java 5, JBoss 4.0.2, Oracle 9i and the GeneralPurposeDatabasePersistencePlugin for EJB Timer persistence. I have changed the JBoss type mapping (in standardjbosscmp-jdbc.xml) for a BLOB to a RAW(2000) because Oracle BLOBs don't work with generic JDBC code.

      Creating timers works fine and the timers execute as expected, calling the appropriate ejbTimeout method. Timer rows appear in the TIMERS table. After a server shutdown and restart, timers are restored with correct data, including the INFO column, which is a RAW(2000) as mentioned above.

      The issue seems to be that, if I cancel a timer from within a Required transaction EJB method, the timer remains in the DB. I can see that the Timer's status was set to CANCEL in the DEBUG statements in the JBoss log. When the server is gracefully shutdown and restarted, the cancelled timer is restored as active.

      Is this intentional/expected behavior? I was expecting that cancel() would remove a persistent Timer. Has anyone else had this issue?

      I have tried searching the forums and read the following threads:
      Phantom timeout
      Ejb timers and persistence reactivation
      They are closely related, but not exactly.

      Vick Fisher

        • 1. More on Persistent JBoss EJB Timers
          Vickj Fisherboss Newbie

          Hi All,

          This is more general follow up comment on using JBoss EJB Timer persistence with Oracle.

          I am working with JBoss 4.0.2 EJB Timer persistence using GeneralPurposeDatabasePersistencePlugin. We use Oracle 9i. Unfortunately Oracle BLOBs do not work generically. In my experience, when using Oracle BLOBs, you must cast to a specific Oracle BLOB type, rather than using pure JDBC.

          To work around this issue, I tried to extend GeneralPurposeDatabasePersistencePlugin and override a few methods to change the column type of INFO to be VARCHAR so I could use an XML form of my INFO objects. That led to a problem with calling the constructor of TimerImpl. All the constructors of TimerImpl are package or private scope, so there is no way to extend that class to make the necessary changes. I also tried directly implementing a new class that implements the Timer interface, only to find out that the DatabasePersistencePolicy casts the results of "List getTimers()" to TimerImpl instead of Timer - thus getting a ClassCast exception.

          Currently, I have changed the JBoss type mapping (in standardjbosscmp-jdbc.xml) for a BLOB to a RAW(2000), which is an unsafe workaround because something somewhere may end up over 2000 bytes and blow up. This column MUST be binary since the GeneralPurposeDatabasePersistencePlugin uses ByteArrayInput/OutputStream to serialize and deserialize into that column.

          I've got it working now with RAW(2000), except for the other issue I'm posting - zombie timers remaining in the DB after timer.cancel() has been called and the EJB transaction has completed.

          Does anyone have a different approach to persistent JBoss EJB Timers with Oracle 9i or higher?

          Vick Fisher

          • 2. Re: Cancelled Persistent EJB Timers not deleted from DB?
            Dimitris Andreadis Master

            fixed in the next release:


            jboss4.0.4RC1 has a lot of timer fixes.