3 Replies Latest reply on May 26, 2011 9:45 AM by fernando_jmt

    RequestScoped bean invoked by a cron Job throws ContextNotActiveException

    fernando_jmt

      Hi,


      I'm using tomcat 7, Weld 1.1.1.Final, and Seam 3.


      I am testing the seam-cron 3.0.0.Apha1 module, which works fine for @Dependent scoped beans, but it doesn't work for @RequestScoped beans. When the cron job is fired the following exception is thrown:




      17:45:00,029 ERROR [org.quartz.core.JobRunShell] Job ticker_job_group.minute-trigger threw an unhandled Exception:
      org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.enterprise.context.RequestScoped






      The bean is this:


      @RequestScoped
      @Transactional(TransactionPropagation.REQUIRED)
      public class TransferenceExpirationService {
          private Log log = LogFactory.getLog(TransferenceExpirationService.class);
      
          @Inject
          protected EntityManager entityManager;
      
      
          public void fire(@Observes @Every Minute minute) {
              log.debug("Minute: " + minute);
          }
      }




      The weld reference document (page 34) states:



      The request and application scopes are also active:
      • during invocations of EJB remote methods,
      • during invocations of EJB asynchronous methods,
      • during EJB timeouts,
      • during message delivery to a message-driven bean,
      • during message delivery to a MessageListener, and
      • during web service invocations.






      I can assume according to the documentation that the request scope should have worked in my example (it is like an EJB timeout), so  I'm wondering if there's something I'm missing or the documentation is not valid for my case.


      I would appreciate any help, thanks.