我已經開始了一個線程,但是,當它試圖訪問實體管理器會拋出異常,因爲 javax.enterprise.context.ContextNotActiveException: WebBeans的作用域類型標註@RequestScoped方面不當前線程中存在ContextNotActiveException同時呼籲entityManger.createNativeQuery使用線程
我應該如何訪問EntityManger螺紋 任何解決方案?
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();
}
}
有沒有對DefaultUserSevice類的任何註解? –
沒有說明爵士 –