6 Replies Latest reply on Mar 10, 2009 5:37 AM by John smith

    EJB Timer still active even after the bean is undeployed !

    John smith Newbie

      Hello,

      i have the following problem:

      I can not kill an ejb timer after the call unregisterTimer method, and the timer is still active even after the ejb is undeployed.

      the source code of my bean is here under :

      package com.test.timer;
      
      import javax.annotation.PreDestroy;
      import javax.annotation.Resource;
      import javax.ejb.EJBException;
      import javax.ejb.Local;
      import javax.ejb.NoSuchObjectLocalException;
      import javax.ejb.Remote;
      import javax.ejb.SessionContext;
      import javax.ejb.Stateless;
      import javax.ejb.Timeout;
      import javax.ejb.Timer;
      import javax.ejb.TimerHandle;
      import javax.ejb.TimerService;
      import javax.ejb.TransactionAttribute;
      import javax.ejb.TransactionAttributeType;
      import javax.ejb.TransactionManagement;
      import javax.ejb.TransactionManagementType;
      import javax.naming.Context;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      
      import org.apache.log4j.Logger;
      
      
      
      
       @Local( ITimerManagerLocal.class)
       @Remote(ITimerManagerRemote.class)
       @TransactionManagement(TransactionManagementType.CONTAINER)
       @TransactionAttribute(TransactionAttributeType.SUPPORTS)
       @Stateless( name = "NotifyExpiration", mappedName="NotifyExpirationRemote")
       public class TimerManagerBean implements ITimerManagerLocal, ITimerManagerRemote {
      
      
       private static final Logger logger = Logger.getLogger ( "EXPIRATION_SERVICE");
      
       @Resource
       private SessionContext sessionContext;
      
       @Resource
       private TimerService timerService;
      
       //--------------------------------------------------------------------------
       // Methods
       //--------------------------------------------------------------------------
       @PreDestroy
       public void unregisterTimer() throws NamingException {
      
       logger.info( "NOTIFY TIMEOUT UNREGISTER");
      
       Context ctx = new InitialContext();
      
       try {
       TimerHandle handle = (TimerHandle) ctx.lookup( "TIMER_JNDI_NAME");
       ctx.unbind("TIMER_JNDI_NAME");
       if (handle != null){
       try {
       Timer expirationTimer = handle.getTimer();
       if (expirationTimer != null){
       expirationTimer.cancel();
       }
       } catch (NoSuchObjectLocalException e) {
       logger.warn( "UNABLE TO UNREGISTER TIME OUT", e);
       } catch (IllegalStateException e) {
       logger.warn( "UNABLE TO UNREGISTER TIME OUT", e);
       } catch (EJBException e) {
       logger.warn( "UNABLE TO UNREGISTER TIME OUT" , e);
       }
       }
       } catch (Throwable thre){
       logger.warn( "UNABLE TO UNREGISTER TIME OUT", thre);
       return;
       }
       }
      
      
       public void registerTimer() throws NamingException {
       unregisterTimer();
       int delai = 10 * 1000;
       Timer expirationTimer = createTimer( delai);
       Context ctx = new InitialContext();
       ctx.bind("TIMER_JNDI_NAME", expirationTimer.getHandle());
       if (logger.isInfoEnabled()){
       logger.info("TIMER REGISTERED " + expirationTimer.getNextTimeout().getTime());
      
       }
       }
      
       private Timer createTimer( int delai)
       {
       try {
       return sessionContext.getTimerService().createTimer(delai, delai, null);
       } catch( Throwable thr) {
       return timerService.createTimer (delai, delai, null);
       }
       }
      
       @Timeout
       //@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
       public void timedOut(Timer obj)
       {
       try {
       if (logger.isDebugEnabled()){
       logger.debug(
       String.format("TIMER WAKEUP at: " + System.currentTimeMillis()));
      
       }
       logger.debug("do something...");
       }catch (RuntimeException e) {
       logger.debug( "TIMER WAKEUP FAILS");
       }
       }
      
      
      }
      
      


      so first i register the timer by calling registerTimer() method, and i wont to kill it by calling unregisterTimer() method. but this does not work, and the timer remains active even after the bean is undeployed.

      If somme one has an idea or workaround to solve this problem ?

      Thank you so match.

      Regard's.

        • 1. Re: EJB Timer still active even after the bean is undeployed
          jaikiran pai Master

           

          but this does not work, and the timer remains active even after the bean is undeployed.


          How did you verify this? Can you post the appropriate logs which show this behaviour?


          • 2. Re: EJB Timer still active even after the bean is undeployed
            John smith Newbie

            I'm sure the timer is not killed because I see in the logs that the timer is still active.

            i will post the log file in the afternoun.

            Thank's.

            • 3. Re: EJB Timer still active even after the bean is undeployed
              jaikiran pai Master

              Also please post the logs which show the undeployment itself, apart from the logs after the undeployment.

              • 4. Re: EJB Timer still active even after the bean is undeployed
                John smith Newbie

                Hello,

                - First I called the method registerTimer ().

                - Secondly, I called the method unregisterTimer (), the method fails and the timer is not killed.

                - Third, I undeploy my ear, and deploy it again, the portion of log file shows that the timer is still active:



                ...
                
                2009-03-09 09:39:20,129 DEBUG [org.jboss.ejb3.proxy.jndiregistrar.JndiSessionRegistrarBase] (HDScanner) Bound javax.naming.Reference into JNDI at "NotifyExpirationRemote"
                2009-03-09 09:39:20,129 DEBUG [org.jboss.ejb3.proxy.jndiregistrar.JndiSessionRegistrarBase] (HDScanner) Bound javax.naming.Reference into JNDI at "NotifyExpiration/remote-com.test.timer.ITimerManagerRemote"
                2009-03-09 09:39:20,129 DEBUG [org.jboss.ejb3.proxy.jndiregistrar.JndiSessionRegistrarBase] (HDScanner) Bound javax.naming.Reference into JNDI at "NotifyExpiration/local"
                2009-03-09 09:39:20,129 DEBUG [org.jboss.ejb3.proxy.jndiregistrar.JndiSessionRegistrarBase] (HDScanner) Bound javax.naming.Reference into JNDI at "NotifyExpiration/local-com.test.timer.ITimerManagerLocal"
                2009-03-09 09:39:20,152 DEBUG [org.jboss.ejb.txtimer.EJBTimerServiceImpl] (HDScanner) createTimerService: org.jboss.ejb.txtimer.TimerServiceImpl@f2938f
                2009-03-09 09:39:20,183 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (HDScanner) setTimerState: created
                2009-03-09 09:39:20,187 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (HDScanner) setTimerState: active
                2009-03-09 09:39:20,190 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) run: [id=1236587223906,target=[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3],remaining=-500649851,periode=10000,active]
                2009-03-09 09:39:20,191 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) setTimerState: in_timeout
                2009-03-09 09:39:20,206 DEBUG [org.jboss.deployers.structure.spi.helpers.AbstractDeploymentContext] (HDScanner) Added component jboss.jacc:id="vfszip:/product/mnfc/jboss/jboss-5.0.0.GA/server/default/deploy/testTimerManager.jar",service=jacc to vfszip:/product/mnfc/jboss/jboss-5.0.0.GA/server/default/deploy/testTimerManager.jar
                2009-03-09 09:39:20,206 DEBUG [org.jboss.system.ServiceCreator] (HDScanner) About to create bean: jboss.jacc:service=jacc,id="vfszip:/product/mnfc/jboss/jboss-5.0.0.GA/server/default/deploy/testTimerManager.jar" with code: org.jboss.deployment.security.EjbJaccPolicy
                2009-03-09 09:39:20,212 DEBUG [org.jboss.system.ServiceCreator] (HDScanner) Created mbean: jboss.jacc:service=jacc,id="vfszip:/product/mnfc/jboss/jboss-5.0.0.GA/server/default/deploy/testTimerManager.jar"
                2009-03-09 09:39:20,212 DEBUG [org.jboss.system.ServiceController] (HDScanner) Creating service jboss.jacc:service=jacc,id="vfszip:/product/mnfc/jboss/jboss-5.0.0.GA/server/default/deploy/testTimerManager.jar"
                2009-03-09 09:39:20,216 DEBUG [org.jboss.system.ServiceController] (HDScanner) starting service jboss.jacc:service=jacc,id="vfszip:/product/mnfc/jboss/jboss-5.0.0.GA/server/default/deploy/testTimerManager.jar"
                2009-03-09 09:39:20,218 DEBUG [org.jboss.deployers.plugins.deployers.DeployersImpl] (HDScanner) Fully Deployed vfszip:/product/mnfc/jboss/jboss-5.0.0.GA/server/default/deploy/testTimerManager.jar
                2009-03-09 09:39:20,233 DEBUG [org.jboss.aop.microcontainer.beans.GenericBeanAspectFactory] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) Creating advice InterceptorsFactory
                2009-03-09 09:39:20,238 WARN [org.jboss.ejb3.interceptors.aop.InterceptorsFactory] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) EJBTHREE-1246: Do not use InterceptorsFactory with a ManagedObjectAdvisor, InterceptorRegistry should be used via the bean container
                2009-03-09 09:39:20,239 DEBUG [org.jboss.aop.microcontainer.beans.GenericBeanAspectFactory] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) Creating advice InterceptorsFactory
                2009-03-09 09:39:20,239 WARN [org.jboss.ejb3.interceptors.aop.InterceptorsFactory] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) EJBTHREE-1246: Do not use InterceptorsFactory with a ManagedObjectAdvisor, InterceptorRegistry should be used via the bean container
                2009-03-09 09:39:20,239 DEBUG [org.jboss.aop.microcontainer.beans.GenericBeanAspectFactory] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) Creating advice InjectInterceptorsFactory
                2009-03-09 09:39:20,241 DEBUG [org.jboss.ejb3.interceptors.aop.InjectInterceptorsFactory] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) new InjectInterceptorsFactory
                2009-03-09 09:39:20,241 DEBUG [org.jboss.ejb3.interceptors.aop.InjectInterceptorsFactory] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) Create interceptor chain for org.jboss.ejb3.aop.ExtendedManagedObjectAdvisor@29708033 on public void com.test.timer.TimerManagerBean.timedOut(javax.ejb.Timer)
                2009-03-09 09:39:20,241 WARN [org.jboss.ejb3.interceptors.registry.InterceptorRegistry] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) applicable interceptors is non-existent for public void com.test.timer.TimerManagerBean.timedOut(javax.ejb.Timer)
                2009-03-09 09:39:20,247 DEBUG [org.jboss.aop.microcontainer.beans.GenericBeanAspectFactory] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) Creating advice InjectInterceptorsFactory
                2009-03-09 09:39:20,247 DEBUG [org.jboss.ejb3.interceptors.aop.InjectInterceptorsFactory] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) new InjectInterceptorsFactory
                2009-03-09 09:39:20,247 DEBUG [org.jboss.ejb3.interceptors.aop.InjectInterceptorsFactory] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) Create interceptor chain for org.jboss.ejb3.aop.ExtendedManagedObjectAdvisor@29708033 on public void com.test.timer.TimerManagerBean.registerTimer() throws javax.naming.NamingException
                2009-03-09 09:39:20,247 WARN [org.jboss.ejb3.interceptors.registry.InterceptorRegistry] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) applicable interceptors is non-existent for public void com.test.timer.TimerManagerBean.registerTimer() throws javax.naming.NamingException
                2009-03-09 09:39:20,251 DEBUG [org.jboss.aop.microcontainer.beans.GenericBeanAspectFactory] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) Creating advice InjectInterceptorsFactory
                2009-03-09 09:39:20,251 DEBUG [org.jboss.ejb3.interceptors.aop.InjectInterceptorsFactory] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) new InjectInterceptorsFactory
                2009-03-09 09:39:20,251 DEBUG [org.jboss.ejb3.interceptors.aop.InjectInterceptorsFactory] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) Create interceptor chain for org.jboss.ejb3.aop.ExtendedManagedObjectAdvisor@29708033 on public void com.test.timer.TimerManagerBean.unregisterTimer() throws javax.naming.NamingException
                2009-03-09 09:39:20,251 WARN [org.jboss.ejb3.interceptors.registry.InterceptorRegistry] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) applicable interceptors is non-existent for public void com.test.timer.TimerManagerBean.unregisterTimer() throws javax.naming.NamingException
                2009-03-09 09:39:20,255 DEBUG [org.jboss.aop.microcontainer.beans.GenericBeanAspectFactory] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) Creating advice InjectInterceptorsFactory
                2009-03-09 09:39:20,255 DEBUG [org.jboss.ejb3.interceptors.aop.InjectInterceptorsFactory] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) new InjectInterceptorsFactory
                2009-03-09 09:39:20,255 DEBUG [org.jboss.ejb3.interceptors.aop.InjectInterceptorsFactory] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) Create interceptor chain for org.jboss.ejb3.aop.ExtendedManagedObjectAdvisor@29708033 on public void com.test.timer.TimerManagerBean.timedOut(javax.ejb.Timer)
                2009-03-09 09:39:20,255 WARN [org.jboss.ejb3.interceptors.registry.InterceptorRegistry] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) applicable interceptors is non-existent for public void com.test.timer.TimerManagerBean.timedOut(javax.ejb.Timer)
                2009-03-09 09:39:20,259 DEBUG [org.jboss.aop.microcontainer.beans.GenericBeanAspectFactory] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) Creating advice InjectInterceptorsFactory
                2009-03-09 09:39:20,259 DEBUG [org.jboss.ejb3.interceptors.aop.InjectInterceptorsFactory] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) new InjectInterceptorsFactory
                2009-03-09 09:39:20,259 DEBUG [org.jboss.ejb3.interceptors.aop.InjectInterceptorsFactory] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) Create interceptor chain for org.jboss.ejb3.aop.ExtendedManagedObjectAdvisor@29708033 on public void com.test.timer.TimerManagerBean.registerTimer() throws javax.naming.NamingException
                2009-03-09 09:39:20,259 WARN [org.jboss.ejb3.interceptors.registry.InterceptorRegistry] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) applicable interceptors is non-existent for public void com.test.timer.TimerManagerBean.registerTimer() throws javax.naming.NamingException
                2009-03-09 09:39:20,263 DEBUG [org.jboss.aop.microcontainer.beans.GenericBeanAspectFactory] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) Creating advice InjectInterceptorsFactory
                2009-03-09 09:39:20,263 DEBUG [org.jboss.ejb3.interceptors.aop.InjectInterceptorsFactory] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) new InjectInterceptorsFactory
                2009-03-09 09:39:20,263 DEBUG [org.jboss.ejb3.interceptors.aop.InjectInterceptorsFactory] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) Create interceptor chain for org.jboss.ejb3.aop.ExtendedManagedObjectAdvisor@29708033 on public void com.test.timer.TimerManagerBean.unregisterTimer() throws javax.naming.NamingException
                2009-03-09 09:39:20,263 WARN [org.jboss.ejb3.interceptors.registry.InterceptorRegistry] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) applicable interceptors is non-existent for public void com.test.timer.TimerManagerBean.unregisterTimer() throws javax.naming.NamingException
                2009-03-09 09:39:20,267 DEBUG [org.jboss.ejb3.interceptors.aop.InterceptorSequencer] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) aroundInvoke [advisedMethod=public void com.test.timer.TimerManagerBean.timedOut(javax.ejb.Timer), unadvisedMethod=public void com.test.timer.TimerManagerBean.timedOut(javax.ejb.Timer), metadata=null, targetObject=com.test.timer.TimerManagerBean@dea498, arguments=[Ljava.lang.Object;@1a36300]
                2009-03-09 09:39:20,269 DEBUG [EXPIRATION_SERVICE] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) TIMER WAKEUP at: 1236587960269
                2009-03-09 09:39:20,270 DEBUG [EXPIRATION_SERVICE] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) do something...
                2009-03-09 09:39:20,271 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) Timer was not registered with Tx, resetting state: [id=1236587223906,target=[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3],remaining=-500639932,periode=10000,in_timeout]
                2009-03-09 09:39:20,271 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) setTimerState: active
                2009-03-09 09:39:30,193 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) run: [id=1236587223906,target=[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3],remaining=-500649854,periode=10000,active]
                2009-03-09 09:39:30,193 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) setTimerState: in_timeout
                2009-03-09 09:39:30,194 DEBUG [org.jboss.ejb3.interceptors.aop.InterceptorSequencer] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) aroundInvoke [advisedMethod=public void com.test.timer.TimerManagerBean.timedOut(javax.ejb.Timer), unadvisedMethod=public void com.test.timer.TimerManagerBean.timedOut(javax.ejb.Timer), metadata=null, targetObject=com.test.timer.TimerManagerBean@dea498, arguments=[Ljava.lang.Object;@17cb2ef]
                2009-03-09 09:39:30,194 DEBUG [EXPIRATION_SERVICE] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) TIMER WAKEUP at: 1236587970194
                2009-03-09 09:39:30,194 DEBUG [EXPIRATION_SERVICE] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) do something...
                2009-03-09 09:39:30,194 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) Timer was not registered with Tx, resetting state: [id=1236587223906,target=[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3],remaining=-500639855,periode=10000,in_timeout]
                2009-03-09 09:39:30,194 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) setTimerState: active
                2009-03-09 09:39:40,195 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) run: [id=1236587223906,target=[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3],remaining=-500649856,periode=10000,active]
                2009-03-09 09:39:40,195 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) setTimerState: in_timeout
                2009-03-09 09:39:40,196 DEBUG [org.jboss.ejb3.interceptors.aop.InterceptorSequencer] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) aroundInvoke [advisedMethod=public void com.test.timer.TimerManagerBean.timedOut(javax.ejb.Timer), unadvisedMethod=public void com.test.timer.TimerManagerBean.timedOut(javax.ejb.Timer), metadata=null, targetObject=com.test.timer.TimerManagerBean@dea498, arguments=[Ljava.lang.Object;@1c7876b]
                2009-03-09 09:39:40,196 DEBUG [EXPIRATION_SERVICE] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) TIMER WAKEUP at: 1236587980196
                2009-03-09 09:39:40,196 DEBUG [EXPIRATION_SERVICE] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) do something...
                2009-03-09 09:39:40,196 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) Timer was not registered with Tx, resetting state: [id=1236587223906,target=[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3],remaining=-500639857,periode=10000,in_timeout]
                2009-03-09 09:39:40,196 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) setTimerState: active
                2009-03-09 09:39:50,198 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) run: [id=1236587223906,target=[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3],remaining=-500649859,periode=10000,active]
                2009-03-09 09:39:50,198 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) setTimerState: in_timeout
                2009-03-09 09:39:50,199 DEBUG [org.jboss.ejb3.interceptors.aop.InterceptorSequencer] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) aroundInvoke [advisedMethod=public void com.test.timer.TimerManagerBean.timedOut(javax.ejb.Timer), unadvisedMethod=public void com.test.timer.TimerManagerBean.timedOut(javax.ejb.Timer), metadata=null, targetObject=com.test.timer.TimerManagerBean@dea498, arguments=[Ljava.lang.Object;@312a17]
                2009-03-09 09:39:50,199 DEBUG [EXPIRATION_SERVICE] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) TIMER WAKEUP at: 1236587990199
                2009-03-09 09:39:50,199 DEBUG [EXPIRATION_SERVICE] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) do something...
                2009-03-09 09:39:50,199 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) Timer was not registered with Tx, resetting state: [id=1236587223906,target=[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3],remaining=-500639860,periode=10000,in_timeout]
                2009-03-09 09:39:50,199 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) setTimerState: active
                2009-03-09 09:39:59,012 DEBUG [com.arjuna.ats.arjuna.logging.arjLogger] (Thread-13) Periodic recovery - first pass <Mon, 9 Mar 2009 09:39:59>
                2009-03-09 09:39:59,012 DEBUG [com.arjuna.ats.arjuna.logging.arjLogger] (Thread-13) StatusModule: first pass
                2009-03-09 09:39:59,012 DEBUG [com.arjuna.ats.txoj.logging.txojLoggerI18N] (Thread-13) [com.arjuna.ats.internal.txoj.recovery.TORecoveryModule_3] - TORecoveryModule - first pass
                2009-03-09 09:39:59,012 DEBUG [com.arjuna.ats.jta.logging.loggerI18N] (Thread-13) [com.arjuna.ats.internal.jta.recovery.info.firstpass] Local XARecoveryModule - first pass
                2009-03-09 09:40:00,200 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) run: [id=1236587223906,target=[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3],remaining=-500649861,periode=10000,active]
                2009-03-09 09:40:00,200 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) setTimerState: in_timeout
                2009-03-09 09:40:00,201 DEBUG [org.jboss.ejb3.interceptors.aop.InterceptorSequencer] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) aroundInvoke [advisedMethod=public void com.test.timer.TimerManagerBean.timedOut(javax.ejb.Timer), unadvisedMethod=public void com.test.timer.TimerManagerBean.timedOut(javax.ejb.Timer), metadata=null, targetObject=com.test.timer.TimerManagerBean@dea498, arguments=[Ljava.lang.Object;@1c28278]
                2009-03-09 09:40:00,201 DEBUG [EXPIRATION_SERVICE] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) TIMER WAKEUP at: 1236588000201
                2009-03-09 09:40:00,201 DEBUG [EXPIRATION_SERVICE] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) do something...
                2009-03-09 09:40:00,201 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) Timer was not registered with Tx, resetting state: [id=1236587223906,target=[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3],remaining=-500639862,periode=10000,in_timeout]
                2009-03-09 09:40:00,201 DEBUG [org.jboss.ejb.txtimer.TimerImpl] (EJB-Timer-1236587223906[target=jboss.j2ee:jar=testTimerManager.jar,name=NotifyExpiration,service=EJB3]) setTimerState: active
                



                if someone has an idea on how to kill the timer?

                Thank's a lot.

                regard's.

                • 5. Re: EJB Timer still active even after the bean is undeployed
                  Jakub Białek Newbie

                  Hi!

                  According to ejb-3.0 spec (page 88) in @PreDestroy method in stateless bean only following method are allowed:

                  - SessionContext methods: getBusinessObject, getEJBHome, getEJBLocalHome, getEJBObject, getEJBLocalObject,getTimerService, lookup
                  - JNDI access to java:comp/env
                  - EntityManagerFactory access

                  as you see 'TimerService and Timer methods' are not mentioned here, so you cannot cancel timer in PreDestroy method.

                  • 6. Re: EJB Timer still active even after the bean is undeployed
                    John smith Newbie

                    i have found the solution :


                    I killed all timers associated with the current bean, for instance :

                    //to be sure that there is not previous timer still running on JBOSS
                     Collection timersList = timerService.getTimers ();
                     for (Object timer: timersList) {
                     if (timer instanceof Timer) {
                     log.debug ("Timer still running, kill it : "+timer);
                     ((Timer)timer).cancel ();
                     }
                     }
                    


                    thank you for your answer.

                    Regard's.