Are EJB timers in Jboss 4.0.2 compliant with EJB 2.1 spec?
viswaprasad Aug 11, 2005 9:53 PMexcerpt 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)
.....
.....
.....