Hi Thomas! Well, we had this problem as well in a Quartz scheduler Extension. And this did lead to the CdiControl approach implemented in OpenWebBeans Test and now moved to DeltaSpike cdise [1]. Please note that this is not yet finished, but will be soon!
The functionality is currently in one API but will be split into two interfaces. The first one provides the control to container-independently start and stop the whole container (OWB or Weld) which can be used to boot CDI in a JavaSE environment without having any implementation specific code in your project. The second part (I still need to factor this out) will give you the ability to start and stop contexts in respect to the current thread. This will again be container independent and hides all the complexity from the user. I hope to be able to finish this work on the weekend (I'm currently pretty busy at $$dayjob in a C project) LieGrue, strub [1] https://git-wip-us.apache.org/repos/asf?p=incubator-deltaspike.git;a=blob;f=deltaspike/cdise/api/src/main/java/org/apache/deltaspike/cdise/api/CdiContainer.java;h=dc8be0b87f4d350ce0539eec2a43590eeb13e88b;hb=HEAD ----- Original Message ----- > From: Thomas Andraschko <zoi...@googlemail.com> > To: MyFaces Discussion <users@myfaces.apache.org> > Cc: > Sent: Thursday, March 15, 2012 3:08 PM > Subject: [CODI] ThreadScoped / EntityManager in a new Thread > > Hi, > > In our webapp, we have an asynchronous XML sender and receiver and we also > need db access with transactions in this thread. > Currently, our EntityManager is procuded in RequestScoped and will not work > in a new thread. > > How can i solve this? > Does any ThreadScoped implementation exists? > > Thanks and best regards, > Thomas >