2 Replies Latest reply on Aug 12, 2005 1:46 PM by Viswa Vutharkar

    Are EJB timers in Jboss 4.0.2  compliant  with EJB 2.1 spec?

    Viswa Vutharkar Newbie

      excerpt from EJB 2.1 Spec section 22.4.2 (last para)


      Timers are persistent objects. In the event of a container crash, any single-event timers that have expired
      during the intervening time before container restart must cause the ejbTimeout method to be invoked
      upon restart. Any interval timers that have expired during the intervening time must cause the ejb-
      Timeout method to be invoked at least once upon restart




      I created an interval timer within my stateless session bean upon the first invocation of a particular business method. The timer got triggered properly every 20 seconds until I stopped the container (issuing CTRL +C). When I restarted the server again after a minute or so...the timer no longer triggered. Not even once.

      Just wondering if this is a bug.


      Also the spec does not put any restrictions on whether the TimerService() or its methods can be accessed from within the ejbCreate() method. But JBoss seems to disallow it...When the SessionContext is already initialised and available for use by the time ejbCreate() is invoked and TimerService could be obtained without problem, then why the access to TimerService() methods is resulting in exceptions and termed illegal?


      -----------stack trace --------------



      18:47:59,365 INFO [STDOUT] setSessionContext(): Context has been set.
      18:47:59,365 INFO [STDOUT] MYSLSBean got created !!
      18:47:59,365 INFO [STDOUT] createTimer() being called ...
      18:47:59,396 ERROR [AllowedOperationsAssociation] TimerService.getTimers should not be access from this bean method: IN_
      EJB_CREATE, allowed is [IN_EJB_TIMEOUT, IN_BUSINESS_METHOD, IN_SERVICE_ENDPOINT_METHOD]
      java.lang.IllegalStateException: TimerService.getTimers should not be access from this bean method: IN_EJB_CREATE


      at org.jboss.ejb.AllowedOperationsAssociation.assertAllowedIn(AllowedOperationsAssociation.java:132)
      at org.jboss.ejb.StatelessSessionEnterpriseContext$TimerServiceWrapper.assertAllowedIn(StatelessSessionEnterpris
      eContext.java:284)
      at org.jboss.ejb.StatelessSessionEnterpriseContext$TimerServiceWrapper.getTimers(StatelessSessionEnterpriseConte
      xt.java:278)
      at com.hp.cluster.MySLSBean.createTimer(MySLSBean.java:132)
      at com.hp.cluster.MySLSBean.ejbCreate(MySLSBean.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:324)
      at org.jboss.ejb.StatelessSessionEnterpriseContext.(StatelessSessionEnterpriseContext.java:63)
      at org.jboss.ejb.plugins.StatelessSessionInstancePool.create(StatelessSessionInstancePool.java:35)
      at org.jboss.ejb.plugins.AbstractInstancePool.get(AbstractInstancePool.java:161)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invokeHome(StatelessSessionInstanceInterceptor.java
      :78)
      .....
      .....
      .....

        • 1. Re: Are EJB timers in Jboss 4.0.2  compliant  with EJB 2.1 s
          Darran Lofthouse Master

          1 - This is the wrong forum for this question.

          2 - The scenario you are describing is a container shut down, the specification only describes what should happen if the container crashes. This has been discussed many times before in the forums. There may also be a JIRA enhancement that covers this but I can not be sure.

          3 - If you have a look at section 7.8.2 of the EJB specification Table 3 shows what operations are allowed from which bean methods.

          In the ejbCreate method you can call getTimerService on the SessionContext but you are not allowed to make use of the returned timer service until the business method is invoked.

          • 2. Re: Are EJB timers in Jboss 4.0.2  compliant  with EJB 2.1 s
            Viswa Vutharkar Newbie

            Thanks for the clarifications and I apologise for mis-posting the question in thw wrong forum. I had a previous question abt beahvior of Timers in clusters and mistakenly posted this next question in the same forum.

            btw, my previous question 'EJB Timers in clusters' is still unanswered...do you happen to know the answer for that one too ? :)

            Thanks.