我在 glassfish3.1 上实例化有状态会话 bean 时遇到问题。
用于使用 @Stateless 会话 bean 的 @Local 接口的 JSF 应用程序的 @ManagedBean(会话范围)并且一切正常。
现在我必须转换为@Stateful bean,当我尝试将有状态 bean 注入托管 bean 时出现异常。
有问题的代码由以下 3 层组成:
@ManagedBean
@SessionScoped
public class ShopBean {
private @EJB ShopAdminInterface sa;
...
}
@Local
public interface ShopAdminInterface {
.... some interfaces
}
@Stateful
public class ShopAdmin implements ShopAdminInterface {
@EJB CoreClassEAO s;
... some implementation
}
CoreClassEAO 为数据库提供了一个访问层,如下所示:
@Stateful
public class CoreClassEAO {
@PersistenceContext
EntityManager em;
.... access to my persistence interface
}
在上一个版本中,当 ShopAdmin 和 CoreClassEAO 都是 @Stateless bean 时,一切都运行良好。但是现在,注入 ShopAdminInterface 会向我抛出异常
更新:我缩小了问题范围:查看我的另一个问题 Injecting @Stateful bean into another @Stateful bean