0
weblogic 10.3.4.0(ejb 3.0)でアプリケーションを停止すると、EJBステートレスのpredestroy faseでタイマをクリーンにします。アプリケーション停止時のタイマキャンセルEJB 3.0
が、WebLogic、このメッセージを上げる
java.lang.IllegalStateException: [EJB:010193]Illegal call to EJBContext method. The bean is in "null" state. It cannot perform 'getting the Timer Service' action(s). Refer to the EJB specification for more details.
マイpreDestroy方法は
@Resource
private TimerService timerService;
@PreDestroy
public void stopMyTimers() {
if(timerService!=null){
for(Timer timer : timerService.getTimers()) {
if(timer!=null) timer.cancel();
}
}
}
Beanが "ヌル" 状態でない場合PreDestroyの前に何かが存在するのですか?
アプリケーションを停止すると、タイマーをキャンセルする方法はありますか?
@javax.ejb.Singleton
// you might need @javax.ejb.Startup as well
public class ShutdownController {
@EJB
private YourEjbWithTimers ejbWithTimers;
@PreDestroy
void shutdown() {
ejbWithTimers.stopMyTimers();
}
}
をしてまで、あなたのstopMyTimers
方法を変更します:
それは '@のPostConstruct'方法 –
しかし、顧客に起動時にそれらをキャンセルする方が簡単ですアプリケーションが停止したときにキャンセルしたい – Kaltresian