JBOSS EAP6 系列二 客户端访问位于EAR中的EJB时,jndi name要遵守的规则

EJB 的 jndi语法(在整个调用远程ejb的过程中语法的遵循是相当重要的)


       参见jboss-as-quickstarts-7.1.1.CR2\ejb-remote\client\src\main\java\org\jboss\as\quickstarts\ejb\remote\client\RemoteEJBClient.java 中的注释:


<span style="font-size:18px;"><span style="font-size:18px;">  // The JNDI lookup name for a stateless session bean has the syntax of:
      // ejb:<appName>/<moduleName>/<distinctName>/<beanName>!<viewClassName>

      // <appName> The application name is the name of the EAR that the EJB is deployed in
      //           (without the .ear).  If the EJB JAR is not deployed in an EAR then this is
      //           blank.  The app name can also be specified in the EAR's application.xml
      //          
      // <moduleName> By the default the module name is the name of the EJB JAR file (without the
      //              .jar suffix).  The module name might be overridden in the ejb-jar.xml
      //
      // <distinctName> : AS7 allows each deployment to have an (optional) distinct name.
      //                  This example does not use this so leave it blank.
      //
      // <beanName>     : The name of the session been to be invoked.
      //
      // <viewClassName>: The fully qualified classname of the remote interface.  Must include
      //                  the whole package name.</span></span>

// The JNDI lookup name for a stateful session bean has the syntax of:

// ejb:<appName>/<moduleName>/<distinctName>/<beanName>!<viewClassName>?stateful

<span style="font-size:18px;"><span style="font-size:18px;"> //
      // <appName> The application name is the name of the EAR that the EJB is deployed in
      //           (without the .ear).  If the EJB JAR is not deployed in an EAR then this is
      //           blank.  The app name can also be specified in the EAR's application.xml
      //          
      // <moduleName> By the default the module name is the name of the EJB JAR file (without the
      //              .jar suffix).  The module name might be overridden in the ejb-jar.xml
      //
      // <distinctName> : AS7 allows each deployment to have an (optional) distinct name.
      //                  This example does not use this so leave it blank.
      //
      // <beanName>     : The name of the session been to be invoked.
      //
      // <viewClassName>: The fully qualified classname of the remote interface.  Must include
      //                  the whole package name.</span></span>

现在我们对上面的语法进行细化,这是最容易出错的地方!

1. 纯EJB jar部署中的bean的访问


1.1 JNDI lookup name for astatelesssession bean has the  syntax of:


<span style="font-size:18px;"><span style="font-size:18px;"><span style="font-size:18px;">    ejb:/<moduleName>/<distinctName>/<beanName>!<viewClassName>
    或者
    ejb:/<moduleName>/<distinctName>//<beanName>!<viewClassName>

    比如:
    "ejb:/jboss-as-ejb-remote-app/CounterBean!" + RemoteCounter.class.getName()
    "ejb:/jboss-as-ejb-remote-app//CounterBean!" + RemoteCounter.class.getName()</span></span></span>

1.2 JNDI lookup name for astatefullsession bean has the  syntax of:

<span style="font-size:18px;"><span style="font-size:18px;">ejb:/<moduleName>/<distinctName>/<beanName>!<viewClassName>?stateful
或者
ejb:/<moduleName>/<distinctName>//<beanName>!<viewClassName>?stateful


比如:
"ejb:/jboss-as-ejb-remote-app/CounterBean!" + RemoteCounter.class.getName()+"?stateful"
"ejb:/jboss-as-ejb-remote-app//CounterBean!" + RemoteCounter.class.getName()+"?stateful"</span></span>

2. 包含在 ear部署中的EJB jar中的bean的访问


2.1 JNDI lookup name for astatelesssession bean has the


syntax of:
<span style="font-size:18px;"><span style="font-size:18px;">ejb:<appName>/<moduleName>/<distinctName>/<beanName>!<viewClassName>
或者
ejb:<appName>/<moduleName>/<distinctName>//<beanName>!<viewClassName>

比如:
"ejb:nms-server-ear/nms-server-ejb/SecuredRemoteSession!" + ISecuredRemoteSession.class.getName()
"ejb:nms-server-ear/nms-server-ejb//SecuredRemoteSession!" + ISecuredRemoteSession.class.getName()

注意: appName 前面没有 斜线 "/"!!! 这是最容易出错的地方!!!
(如果以斜线开头,表明是ejb jar不是在 ear中部署的!!!)</span></span>

2.2 JNDI lookup name for astatefullsession bean has the syntax of:

<span style="font-size:18px;"><span style="font-size:18px;">ejb:<appName>/<moduleName>/<distinctName>/<beanName>!<viewClassName>?stateful
或者
ejb:<appName>/<moduleName>/<distinctName>//<beanName>!<viewClassName>?stateful

注意: <span style="color:#FF0000;">appName 前面没有 斜线 "/"!!! 这是最容易出错的地方!!!</span>
(如果以斜线开头,表明是ejb jar不是在 ear中部署的!!!)</span></span>

总结

      看英文文档耐人寻味啊,好好学习英语吧,外网的资料更加的可靠啊!

评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值