Injecting same EJB into two different managed beans not working

自古美人都是妖i 提交于 2019-12-03 10:15:40

It was my mistake, I was trying to use the ejb in the constructor as follows -

public MyBean2() {
    entities = myEjb.getAllEntities(); //this is where the problem is, myEjb is null
}

Now, I know that the ejb is injected only after the container is done instantiating the managed bean.

Now I have.

@PostConstrut
private void init() {
    entities = myEjb.getAllEntities();
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!