[英]JNDI loopup for a remote client accessing an EJB deployed in JBOSS AS (7.1.1 final)
I have created a simple EJB 3.0 application, deployed in JBOSS 7.1.1 final. 我创建了一个简单的EJB 3.0应用程序,该应用程序最终部署在JBOSS 7.1.1中。
EJB 1: EJB 1:
Interface 接口
package com.example.server.local.bean;
import javax.ejb.Local;
@Local
public interface UtilLocalBeanLocal {
public String addString();
}
Class implementing this interface: 实现此接口的类:
package com.example.server.local.bean;
import javax.ejb.Local;
import javax.ejb.Stateless;
@Stateless
@Local(value=UtilLocalBeanLocal.class)
public class UtilLocalBean implements UtilLocalBeanLocal {
public UtilLocalBean() {
}
@Override
public String addString() {
return "Added from Local bean";
}
}
So, this EJB i am creating to be "locally" used by another EJB. 因此,我正在创建该EJB以供另一个EJB使用“本地”。
EJB 2: EJB 2:
Interface 接口
package com.example.bean.session;
import javax.ejb.Remote;
@Remote
public interface FirstBeanRemote {
public String callMe();
}
Class implementing this interface. 实现此接口的类。
package com.example.bean.session;
import javax.ejb.EJB;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import com.example.server.local.bean.UtilLocalBeanLocal;
@Stateless
@Remote(value=FirstBeanRemote.class)
public class FirstBean implements FirstBeanRemote {
@EJB
private UtilLocalBeanLocal utilLocalBeanLocal;
public FirstBean() {
}
@Override
public String callMe() {
return "Hi there!" + utilLocalBeanLocal.addString();
}
}
00:34:15,928 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-5) JNDI bindings for session bean named FirstBean in deployment unit subdeployment "EJB30TestProj.jar" of deployment "EJB30TestProjEAR.ear" are as follows:
java:global/EJB30TestProjEAR/EJB30TestProj/FirstBean!com.example.bean.session.FirstBeanRemote
java:app/EJB30TestProj/FirstBean!com.example.bean.session.FirstBeanRemote
java:module/FirstBean!com.example.bean.session.FirstBeanRemote
java:jboss/exported/EJB30TestProjEAR/EJB30TestProj/FirstBean!com.example.bean.session.FirstBeanRemote
java:global/EJB30TestProjEAR/EJB30TestProj/FirstBean
java:app/EJB30TestProj/FirstBean
java:module/FirstBean
ejb:EJB30TestProjEAR/EJB30TestProj//FirstBean!com.example.bean.session.FirstBeanRemote
It is difficult to understand how this JNDI bindings work. 很难理解这个JNDI绑定是如何工作的。 JBOSS outputs a different JNDI and in reality what works is different one.
JBOSS输出不同的JNDI,而实际上起作用的是不同的JNDI。
Can anyone please demystify this? 有人可以揭开这个神秘面纱吗? (how to decide which JNDI bindings will work in different scenarios and any further pointers)
(如何确定哪些JNDI绑定将在不同的场景下工作以及任何其他指针)
The binding values that you mention are prepared for lookup locally, let say into the server that you publish the ejb. 您提到的绑定值已准备就绪,可以在本地查找,比如说在您发布ejb的服务器中。 global, module, app are the scopes limit and in which you can use each one.
全局,模块,应用程序是作用域限制,您可以在其中使用每个限制。 For example, you could lookup a ejb from other ejb of the same ejb-module using module scope but you couldn't lookup it from another ejb-module even being modules of the same app (ear or war), you must use at least app scope for that, and you can use app or global in both scenarios.
例如,您可以使用模块作用域从同一ejb模块的其他ejb查找一个ejb,但是即使是同一应用程序(ear或war)的模块,也无法从另一个ejb模块进行查找,您必须至少使用应用范围,您可以在两种情况下使用app或global 。
I strongly suggest you to take the time to read Jboss AS7 JNDI Referencia but to know about remote lookup go to Remote JNDI section 我强烈建议您花些时间阅读Jboss AS7 JNDI Referencia,但要了解远程查找,请转至“ 远程JNDI”部分
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.