Hi Manuel! Asynchronous Servlet requests are a bit different than manually forking a new Thread. Neither OWB nor Weld use asyncSupported atm.
The CDI EG is already discussing this feature and I guess we will add official support for it in CDI-1.1. LieGrue, strub ----- Original Message ----- > From: Manuel Hartl <manuel.ha...@kobil.com> > To: MyFaces Discussion <users@myfaces.apache.org> > Cc: > Sent: Friday, February 17, 2012 11:40 AM > Subject: Re: CODI+OWB+Scheduler, ContextNotActiveException > > Hi Mark, > > i would slightly disagree to that. > > i think it should at least be possible to use Request and SessionScope > during an AsyncContext of servlet api 3. This AsyncContext is somehow > associated to a specific servlet request and so IMHO Request- and > Session-Scopes could be provided. > > Greetings, > Manuel. > > >> In fact, asynchronous tasks should not even rely on @SessionScoped or > @RequestScoped because they do not exist outside a servlet request ;) >> >> LieGrue, >> strub >> >> >> >> ----- Original Message ----- >>> From: Gerhard Petracek <gerhard.petra...@gmail.com> >>> To: MyFaces Discussion <users@myfaces.apache.org> >>> Cc: >>> Sent: Friday, February 17, 2012 10:58 AM >>> Subject: Re: CODI+OWB+Scheduler, ContextNotActiveException >>> >>> hi erwin, >>> >>> first of all: welcome @ myfaces! >>> >>> for a conversation a window is needed. therefore, the current > conversation >>> can't be resolved outside of a faces request. >>> since it's possible to destroy the window-context at any time, it > isn't >>> suggested to use such scopes in an asynchronous task at all. >>> >>> regards, >>> gerhard >>> >>> http://www.irian.at >>> >>> Your JSF/JavaEE powerhouse - >>> JavaEE Consulting, Development and >>> Courses in English and German >>> >>> Professional Support for Apache MyFaces >>> >>> >>> >>> 2012/2/17 Bonhold, Erwin <erwin.bonh...@atos.net> >>> >>>> Hi all, >>>> >>>> at first, CDI + CODI is really cool stuff for building a webapp. >>>> >>>> 1) Our Environment: >>>> We are using OWB 1.1.3, CODI 1.0.2 on a Tomcat 7 environment with > CODI >>>> @Transactional. >>>> >>>> Database Producer: >>>> @PersistenceContext(unitName = "myunit") >>>> private EntityManager extendedEntityManager; >>>> >>>> @Produces >>>> @ConversationScoped >>>> @MyQualifier >>>> public ExtendedEntityManager createExtendedEntityManager() { >>>> return new ExtendedEntityManager(this.extendedEntityManager); >>>> } >>>> >>>> public void dispose(@Disposes @Siemens ExtendedEntityManager >>>> extendedEntityManager) { >>>> if (extendedEntityManager.isOpen()) { >>>> extendedEntityManager.close(); >>>> } >>>> } >>>> >>>> -DatabaseService which gets above EntityManager injected >>>> -OtherServices which getting the database Service injected >>>> >>>> >>>> 2) The Problem: >>>> Using Quartz, Seam Cron or the following class, which creates a > thread, >>>> leads into the same problem. >>>> >>>> @ApplicationScoped >>>> public class ApplicationTimer { >>>> >>>> @Inject >>>> private Log log; >>>> >>>> @Inject >>>> private OtherService otherService; // gets databaseService > injected, >>>> databaseService gets EntityManager injected >>>> >>>> public void init() { >>>> log.info("initialize timer thread"); >>>> try { >>>> otherService.doSomething(); // WORKS in Context of this >>>> ApplicationScoped bean >>>> } catch (Exception e) { >>>> log.error(e); >>>> } >>>> >>>> Thread timer = new Thread() { >>>> public void run() { >>>> while (true) { >>>> log.info("That's the thread"); >>>> try { >>>> otherService.doSomething(); // EXCEPTION occurs in Child > Thread >>>> Thread.sleep(5000); >>>> } catch (Exception e) { >>>> log.error(e); >>>> } >>>> } >>>> } >>>> }; >>>> timer.start(); >>>> } >>>> } >>>> >>>> An exception >>>> javax.enterprise.context.ContextNotActiveException: WebBeans > context with >>>> scope type annotation @ConversationScoped does not exist within > current >>>> thread >>>> occurs >>>> >>>> We also tried to start a (javax) Conversation. Leads into the same >>>> Excpetion with ... a @RequestScoped does not exist. >>>> >>>> The child thread is not in context of a web request, we guess the >>>> EntityManager have to (as descriped in CODI doc). >>>> >>>> But how to solve this problem? >>>> Is there a possibility to create/provide an appropriate context to > the >>>> child thread or to start scheduled services in another way? >>>> >>>> >>>> Best Regards >>>> Erwin >>>> > > > -- > Dipl. Inform. Manuel Hartl > Software Architect > > FlexSecure-Logo KobilGroup-Logo > > FlexSecure GmbH > Industriestr. 12 > D - 64297 Darmstadt > Tel: +49 (0) 6151 501 23-18 > Fax: +49 (0) 6151 501 23-19 > > E-Mail: ha...@flexsecure.de > Internet: www.flexsecure.de > > Geschäftsführer: > Erwin Stallenberger, Markus Ruppert > > Amtsgericht Darmstadt HRB 8036 > Umsatzsteuernummer: DE 214745269 >