jakarta-ee - 了解 Glassfish 控制台 JNDI 输出

标签 jakarta-ee netbeans glassfish jndi ejb-3.0

当我部署我的 EJB 模块(包含一个 session bean)时;我在 Glassfish 控制台(在 Netbeans 中)中看到了以下输出:

Info:   EJB5181:Portable JNDI names for EJB NewSessionBean: [java:global/EJBModule1/NewSessionBean!com.Hello.NewSessionBeanRemote, java:global/EJBModule1/NewSessionBean]
Info:   EJB5182:Glassfish-specific (Non-portable) JNDI names for EJB NewSessionBean: [com.Hello.NewSessionBeanRemote, com.Hello.NewSessionBeanRemote#com.Hello.NewSessionBeanRemote]

我有两个问题:

1) Why does the remote interface have a JNDI reference? I thought it was just the EJB.
2) Why is there a comma, which appears to separate two JNDI references per line?

最佳答案

1) Why does the remote interface have a JNDI reference? I thought it was just the EJB.

它不是具有 JNDI 引用的 RemoteInterface,它只是一个可移植的 JNDI 引用,其中包括实现的接口(interface)的名称。

下面的解释来自here :

Client applications need to use global JNDI name to lookup an EJB. All along the ejb specifications had been silent about portability of such global jndi names. This allowed each vendor to assign a global jndi names to EJBs in a vendor specific way. This meant that the client code that performed a lookup using global JNDI names were inherently non portable across appserver vendor implementations.

EJB 3.1 solves the above problem by mandating that every container must assign (at least one) well defined global JNDI names to EJBs. The general syntax of a (portable) global JNDI name of an EJB is of the form:

java:global/[<application-name>]/<module-name>/<bean-name>!<fully-qualified-bean-interface-name>

In addition to the above name, if the EJB exposes just a single client view (that is it implements just one interface or the no interface view), the container is also mandated to map the bean to

java:global/[<application-name>]/<module-name>/<bean-name>

Where

  1. <application-name> defaults to the bundle name (.ear file name) without the bundle extension. This can be overridden in application.xml. Also, is applicable only if the bean is packaged inside a .ear file.
  2. <module-name> defaults to bundle name (.war or .jar) without the bundle extension. Again, this can be overridden in ejb-jar.xml.
  3. <bean-name> defaults to the unqualified class name of the bean. However, if @Stateful or @Stateless or @Singleton uses the name attribute, then the value specified there will be used as the bean name.

2) Why is there a comma, which appears to separate two JNDI references per line?

因为逗号用于分隔列表中的条目:) 问题 1 的答案也应该回答这个问题,有一个条目只包含 bean 名称和一个条目包含 bean 名称 + 接口(interface)名称。

关于jakarta-ee - 了解 Glassfish 控制台 JNDI 输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40018087/

相关文章:

java - 如何在init和doget之间共享变量?

java - Glassfish 和 Tomcat

java - 我可以使用 Glassfish 从多个虚拟客户端访问本地主机吗?

java - 应用服务器集群与 Terracotta

Glassfish v3 servlet 容器

java - JAX-RS 使用的无状态 EJB 中的 @Context 注入(inject)

java - 如何在 JSP 页面中使用 jar 文件中的类?

java - UserTransaction 和 EntityTransaction 的区别

java - 如何在netbean6.7中开发和运行ejb?

c++ - Netbeans 7.2 显示 "Unable to resolve identifier",尽管构建成功