gpt4 book ai didi

java - 在 Web 应用程序中 @Inject @Remote EJB

转载 作者:行者123 更新时间:2023-12-02 11:04:31 25 4
gpt4 key购买 nike

是否可以在 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

,您可以做的是为远程接口(interface)提供一个字段生成器

关于java - 在 Web 应用程序中 @Inject @Remote EJB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51088010/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com