简体   繁体   English

@在Web应用程序中注入@Remote EJB

[英]@Inject a @Remote EJB in Web Application

Is it possibile to @Inject a @Remote EJB in a Web Application? 在Web应用程序中@Inject @Remote EJB是否可行? I'm running on Glassfish 5 and I'm deploying an EAR (EJB + WAR). 我在Glassfish 5上运行,并且正在部署EAR(EJB + WAR)。

When I annotate the EJB interface with @Local CDI works, with @Remote not. 当我使用@Local CDI注释EJB接口时,不使用@Remote
What might be the cause? 可能是什么原因?

By the way, using @EJB instead of @Inject works flawlessly, but I'm up to solve the @Inject issue. 顺便说一句,使用@EJB而不是@Inject可以完美地工作,但是我要解决@Inject问题。

CDI is not able to resolve remote ejb beans. CDI无法解析远程ejb Bean。 As per the specs 3.2.2 按照规范3.2.2

The unrestricted set of bean types for a session bean contains all local interfaces of the bean and their superinterfaces. 会话Bean的不受限制的Bean类型集包含该Bean的所有本地接口及其超级接口。 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. 如果会话Bean具有无接口视图,则无限制的Bean声明会话Bean 41类型集将包含Bean类和所有超类。 In addition, java.lang.Object is a bean type of every session bean. 另外,java.lang.Object是每个会话bean的bean类型。 Remote interfaces are not included in the set of bean types. 远程接口不包括在Bean类型集中。

What you can do is to have a field producer for the remote interfaces, if you must use CDI injections rather than @EJB 如果必须使用CDI注入而不是@EJB ,您可以做的是为远程接口提供一个字段生成器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM