6 Replies Latest reply on May 3, 2006 4:01 AM by parallax

    Timer problem

    adamw

      Hello,
      I am using the timer service in a very simple way - starting the timer from a service POJO, and after each timeout cancelling it and starting anew. So the code looks like:

      @Timeout
      public void timeoutHandler(Timer timer) {
      try {
      (...) - do some timer-things.

      // Avoiding WARN.
      timer.cancel();

      ctx.getTimerService().createTimer(new Date(new Date().getTime() + interval),
      null);
      } catch (MalformedObjectNameException e) {
      e.printStackTrace();
      }
      }

      The timer.cancel() is there to avoid getting this exception on each timeout:

      22:09:34,302 WARN [TimerImpl] Timer was not registered with Tx, reseting state: [id=3target=[target=jboss.j2ee:service=EJB3,name=org.jboss.forge.service.ForgeTimer],remaining=-6872,periode=0,in_timeout]

      Which is true, as I'm not using transactions at all - and I don't want to, I just don't need them. But I wanted to get rid of it from my logs and added the timer.cancel() as a user advised me to do in this post: http://www.jboss.org/index.html?module=bb&op=viewtopic&t=67977.

      Everything works well but once I got the exception that is below and the timer stopped working. Any ideas what could have caused it? Maybe I shouldn't cancel the timer? How to get rid of that warning then?

      13:58:46,029 ERROR [TimerImpl] Cannot register txtimer with Tx: [id=15target=[target=jboss.j2ee:service=EJB3,name=org.jboss.forge.service.ForgeTimer],remaining=-372273,periode=0,in_timeout]
      13:58:46,345 ERROR [TimerServiceImpl] Cannot create txtimer
      java.lang.IllegalStateException: Unable to persist timer
      at org.jboss.ejb.txtimer.DatabasePersistencePolicy.insertTimer(DatabasePersistencePolicy.java:138)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
      at org.jboss.mx.util.JMXInvocationHandler.invoke(JMXInvocationHandler.java:273)
      at $Proxy86.insertTimer(Unknown Source)
      at org.jboss.ejb.txtimer.TimerServiceImpl.createTimer(TimerServiceImpl.java:212)
      at org.jboss.ejb.txtimer.TimerServiceImpl.createTimer(TimerServiceImpl.java:178)
      at org.jboss.forge.service.ForgeTimer.scheduleTimer(ForgeTimer.java:29)
      at org.jboss.forge.service.ForgeTimer.timeoutHandler(ForgeTimer.java:49)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:99)
      at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:32)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:66)
      at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:61)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:39)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:91)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      at org.jboss.ejb3.stateless.StatelessContainer.callTimeout(StatelessContainer.java:96)
      at org.jboss.ejb.txtimer.TimerImpl$TimerTaskImpl.run(TimerImpl.java:473)
      at java.util.TimerThread.mainLoop(Timer.java:512)
      at java.util.TimerThread.run(Timer.java:462) Caused by: org.jboss.util.NestedSQLException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=takeshi/33, BranchQual=, localId=33]; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=takeshi/33, BranchQual=, localId=33])
      at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:79) at org.jboss.ejb.txtimer.GeneralPurposeDatabasePersistencePlugin.insertTimer(GeneralPurposeDatabasePersistencePlugin.java:142)
      at org.jboss.ejb.txtimer.DatabasePersistencePolicy.insertTimer(DatabasePersistencePolicy.java:134)
      ... 37 more Caused by: javax.resource.ResourceException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=takeshi/33, BranchQual=, localId=33]
      at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:331)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:462) at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:894)
      at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:73)
      ... 39 more

      --
      Adam

        • 1. Re: Timer problem
          adamw

          This issue reporoduces only on AS 4.0.3RC2 - but I haven't noted any regularity, it seems to be random. On 4.0.3RC1 it seems to work fine.

          • 2. Re: Timer problem
            danikenan

            I added the following to conf/log4j.xml to not print the irretating warning message:

             <category name="org.jboss.ejb.txtimer.TimerImpl">
             <priority value="ERROR"/>
             </category>
            


            • 3. Re: Timer problem
              bill.burke

              I didn't see this on 4.0.3 (out soon). Let me know if it pops up again.

              • 4. Re: Timer problem
                adamw

                Hello,
                I've upgraded to AS 4.0.3 and EJB3 RC3, and I still see the warning pop out on every timer timeout (precisely when the timer-handling function ends a new timer is scheduled). Luckliy I haven't seen the exception.

                The warning is:

                18:00:52,014 WARN [TimerImpl] Timer was not registered with Tx, reseting state: [id=6target=[target=jboss.j2ee:service=EJB3,name=org.jboss.shotoku.svn.service.SvnServiceTimer],remaining=-3001,periode=0,in_timeout]
                


                • 5. Re: Timer problem
                  adamw

                  Anybody has any ideas on how to get rid of this warning in a nice way?

                  The code that produces it is:

                  @Stateless
                  @Local(MyTimerLocal.class)
                  public class MyTimer {
                   public void scheduleTimer(long interval) {
                   ctx.getTimerService().createTimer(new Date(new Date().getTime() + interval),
                   null);
                   }
                  
                   @Timeout
                   public void timeoutHandler(Timer timer) {
                   try {
                   /* some operations */
                  
                   scheduleTimer(ssi.getTimerInterval());
                   } catch (MalformedObjectNameException e) {
                   e.printStackTrace();
                   }
                   }
                  }
                  


                  • 6. Re: Timer problem
                    parallax

                    I am also experiencing the same problem. I am using JBOSS 4.0.3SP1-1, any ideas on the resolution. I have already tries bumping the TransactionTimeout for TransactionManagerService in jnoss-service.xml but it did not make a difference.