1 Reply Latest reply on Apr 14, 2016 3:00 AM by mkouba

    Creating a new Thread with CDI

    kalaivani_s

      HI,

       

      We are using JSF2.0, Richfaces and CDI in a tomcat environment. Our requirement is to do a UI processing in a background thread and fetch data.  So we create a thread pool and do the processing ( like fetching the data from database). Now we want to push this content to UI using Push Topic of Richfaces. Since the thread we have created manually does not have all the related objects( esp session relation information), using the push context and related objects fails with "No Context available". Creating the bound context also does not help as it does not contain any of the session relation information as the UI thread. How to we link the thread we have created with CDI so it gets the context?

        • 1. Re: Creating a new Thread with CDI
          mkouba

          Hi,

          which CDI scope exactly do you need? Application scope and @Dependent should work in manually created threads. Request, session and conversation scopes probably do not make much sense here - as you mentioned, there is no associated request or HTTP session.