This content has been marked as final.
Show 1 reply
-
1. Re: Use an ejbTimer in a CDI SessionScoped Bean
mkouba Aug 28, 2012 7:35 AM (in response to developer251)Hi Max,
I don't think so. Firstly EJB spec disallows timers for SFSBs (18.2 Bean Provider’s View of the Timer Service):
Timers can be created for stateless session beans, singleton session beans, message-driven beans, and 2.1 entity beans. Timers cannot be created for stateful session beans.
Secondly CDI session context is only active during the service() method of any servlet in the web application, during the doFilter() method of any servlet filter and when the container calls any HttpSessionListener, AsyncListener or ServletRequestListener (web request in short). In other words your session scoped CDI bean would not be available during the timeout callback invocation...
However if you don't need to manipulate the session scoped bean during timeout place the timer on SLSB and identify it with session id... HTH.