I have started a thread but when it try to access entity Manager it throws exception as javax.enterprise.context.ContextNotActiveException: WebBeans context with scope type annotation @RequestScoped does not exist within current thread
How should I access EntityManger with thread any solution?
public class SchedulerForData {
@Inject
private DefaultUserSevice userSevice;
public void beepForAnHour() {
long initialDelay;
final Runnable beeper = new Runnable() {
public void run() {
userSevice.getData();
}
scheduler.scheduleAtFixedRate(beeper, 60, 30, TimeUnit.SECONDS);
}
}
}
public class DefaultUserSevice {
@Inject
EntityManager entityManger;
public void getData(){
List resultList = entityManager.createNativeQuery("Select * from USER").getResultList();
}
}