是否可以在 Web 应用程序中@Inject
@Remote
EJB?
我正在 Glassfish 5 上运行,并且正在部署 EAR(EJB + WAR)。
当我使用 @Local
注释 EJB 接口(interface)时,CDI 可以工作,而使用 @Remote
则不行。
可能是什么原因?
顺便说一句,使用 @EJB
而不是 @Inject
可以完美地工作,但我准备解决 @Inject
问题。
最佳答案
CDI 无法解析远程 ejb bean。根据规范 3.2.2
The unrestricted set of bean types for a session bean contains all local interfaces of the bean and their superinterfaces. If the session bean has a no-interface view, the unrestricted set of bean Declaring a session bean 41 types contains the bean class and all superclasses. In addition, java.lang.Object is a bean type of every session bean. Remote interfaces are not included in the set of bean types.
如果您必须使用 CDI 注入(inject)而不是 @EJB
关于java - 在 Web 应用程序中 @Inject @Remote EJB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51088010/