1
我对JBoss和注解颇为陌生。我有以下代码示例。不相关的细节被删除。EJB Singleton服务在部署时失败
@Singleton
@Startup
public class SomeBean {
@Resource
TimerService timerService;
@Inject
AnotherSingleton anotherOne;
Timer timer;
@PostConstruct
private void ejbCreate() {
timer = timerService.createIntervalTimer(0, interval, tc);
}
@Timeout
public void run() throws Exception {
}
}
@Singleton
public class AnotherSingleton {
@Inject
Repository rep;
}
有情况下,当战争在JBoss部署失败与库生产异常(在另一个JBoss的服务不可用)。
Caused by: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
所以过程与
WFLYCTL0186: Services which failed to start: service jboss.deployment.unit."someservices-view.war".component.SomeBean.START
我有什么选择结束? 我可以告诉JBoss在启动时不要@注入bean,但是当代码由定时器执行时? 我能以某种方式捕捉异常吗? @Schedule没有问题因为我需要配置Timer。
感谢提示。实例<>的解决方案似乎工作得很好。 – Eruanno
@Eruanno如果此答案解决了您的问题,请通过选中答案旁边的复选标记来接受此问题。 –