从app调用WebSphere Full Profile(v7)上托管的远程EJB。在Liberty

时间:2015-11-18 17:20:14

标签: websphere-liberty

我有:

  • 应用程序A在Liberty Profile(8.5.5.7)中运行
  • 应用程序B在WAS Full Profile V7中运行,托管名为MyBean的EJB。

我想从应用程序A调用MyBean的方法。

我根据以下文档以编程方式使用以下代码执行MyBean查找:http://www-01.ibm.com/support/knowledgecenter/?lang=en#!/SSEQTP_8.5.5/com.ibm.websphere.wlp.doc/ae/twlp_ejb_remote.html

String corbaURL = "corbaname::wasv7Server:wasv7Port#ejb/global/B/MyBean/beans.\\MyBean!com\\.acme\\.MyBeanRemoteInterface";
Object ref = new InitialContext().lookup(corbaURL);
// .. boilerplate code for narrowing the remote object and calling the remote method.

自由应用程序。 A正在运行,启用了ejbRemote-3.2功能。 部署在WAS7完整配置文件中的应用程序B具有应用程序名称B和EJB模块MyBean,MyBean的部署描述符为:

<session id="Session_beans.MyBean">
    <ejb-name>beans.MyBean</ejb-name>
    <home>com.acme.MyBeanHome</home>
    <remote>com.acme.MyBeanRemote</remote>
    <ejb-class>com.acme.MyBean</ejb-class>
    ...
</session>

在app中执行查找时。 A(在Liberty中)我得到了一个N​​ameNotFoundException, 我想知道WAS Full Profile V7上的LocationService是否理解自V7以来自由发送的corba名称URL,afaik,不支持JEE6;如果是这种情况,我如何从Liberty Profile中运行的A调用bean MyBean?我可以使用ejbRemote-3.2功能,只使用不同的corba名称URL,如果是这样,使用正确的URL是什么?

更新

根据@bkail建议将查找URL更改为:

String corbaURL = "corbaname::wasv7Server:wasv7Port#beans\\.MyBean" ;
// dumpNameSpace shows: 
// (top)/nodes/napp_srmwrk1_app-FULL/servers/AppServer/beans.MyBean
// 8    Bound Java type: com.acme.MyBeanHome
// 8    Local Java type: org.omg.stub.java.rmi._Remote_Stub

更改后仍然获得NameNotFoundException。堆栈跟踪是:

16:21:35.580 [Default Executor-thread-51] ERROR qsr - NamingException
javax.naming.NameNotFoundException: null
at     
com.sun.jndi.cosnaming.ExceptionMapper.mapException(ExceptionMapper.java:61) ~ [na:1.8.0_60]
at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:500) ~[na:1.8.0_60]
at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:539) ~[na:1.8.0_60]
at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:205) ~[na:1.8.0_60]
at org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:161) ~[na:na]
at javax.naming.InitialContext.lookup(InitialContext.java:417) ~[na:1.8.0_60]
at net.gbm.App.doGet(App.java:65) ~[mnr.war:na]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687) [com.ibm.ws.javaee.servlet.3.1_1.0.10.jar:na]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [com.ibm.ws.javaee.servlet.3.1_1.0.10.jar:na]
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1287) [com.ibm.ws.webcontainer_1.1.10.jar:na]
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:778) [com.ibm.ws.webcontainer_1.1.10.jar:na]
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:475) [com.ibm.ws.webcontainer_1.1.10.jar:na]
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1158) [com.ibm.ws.webcontainer_1.1.10.jar:na]
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:4867) [com.ibm.ws.webcontainer_1.1.10.jar:na]
at com.ibm.ws.webcontainer31.osgi.webapp.WebApp31.handleRequest(WebApp31.java:523) [com.ibm.ws.webcontainer31_1.0.10.jar:na]
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.handleRequest(DynamicVirtualHost.java:297) [com.ibm.ws.webcontainer_1.1.10.jar:na]
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:997) [com.ibm.ws.webcontainer_1.1.10.jar:na]
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:262) [com.ibm.ws.webcontainer_1.1.10.jar:na]
at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:955) [com.ibm.ws.transport.http_1.0.10.jar:na]
at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.ready(HttpDispatcherLink.java:341) [com.ibm.ws.transport.http_1.0.10.jar:na]
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:470) [com.ibm.ws.transport.http_1.0.10.jar:na]
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleNewRequest(HttpInboundLink.java:404) [com.ibm.ws.transport.http_1.0.10.jar:na]
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.processRequest(HttpInboundLink.java:284) [com.ibm.ws.transport.http_1.0.10.jar:na]
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.ready(HttpInboundLink.java:255) [com.ibm.ws.transport.http_1.0.10.jar:na]
at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:174) [com.ibm.ws.channelfw_1.0.10.jar:na]
at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:83) [com.ibm.ws.channelfw_1.0.10.jar:na]
at com.ibm.ws.tcpchannel.internal.WorkQueueManager.requestComplete(WorkQueueManager.java:504) [com.ibm.ws.channelfw_1.0.10.jar:na]
at com.ibm.ws.tcpchannel.internal.WorkQueueManager.attemptIO(WorkQueueManager.java:574) [com.ibm.ws.channelfw_1.0.10.jar:na]
at com.ibm.ws.tcpchannel.internal.WorkQueueManager.workerRun(WorkQueueManager.java:929) [com.ibm.ws.channelfw_1.0.10.jar:na]
at com.ibm.ws.tcpchannel.internal.WorkQueueManager$Worker.run(WorkQueueManager.java:1018) [com.ibm.ws.channelfw_1.0.10.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_60]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_60]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_60]
Caused by: org.omg.CosNaming.NamingContextPackage.NotFound:   IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:72) ~[com.ibm.ws.org.apache.yoko.corba.spec.1.5_1.0.10.jar:1.8.0_60]
at org.omg.CosNaming._NamingContextStub.resolve(_NamingContextStub.java:251) ~[com.ibm.ws.org.apache.yoko.corba.spec.1.5_1.0.10.jar:1.8.0_60]
at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:486) ~[na:1.8.0_60]
... 31 common frames omitted

谢谢,

2 个答案:

答案 0 :(得分:1)

&#34;在Liberty配置文件中使用带有远程接口的企业JavaBeans&#34;中列出的corbaname:个URL topic是用于访问Liberty概要文件中运行的EJB的名称。要连接到完整配置文件服务器上的EJB,您需要使用完整配置文件中的绑定名称,该配置文件可能以ejb/...而不是ejb/global/...开头。请参阅&#34;默认绑定模式&#34;知识中心中EJB 3.0 application bindings overview主题的部分。

与Liberty配置文件不同,完整配置文件将JNDI默认命名空间镜像到CosNaming上下文,因此您应该从SystemOut.log中的CNTR0167I消息中复制相关的JNDI名称(执行的JNDI名称)不java:global开头。或者,在完整配置文件上运行PROFILE_HOME/bin/dumpNameSpace命令以转储命名空间,您应该能够找到绑定名称。

答案 1 :(得分:0)

让我分享一下我昨天做过的非常相似的工作经历。 希望这有助于搜索stackoverflow的人。

首先我下载了​​Wlp8.5.5.8并尝试添加ejbRemote3.2等功能。由于我不知道的原因,它无法使用。 然后我用Google搜索找到具有ejbRemote3.2功能的wlp 下载了 为ServerConfiguration添加了以下功能。 如何将这些功能添加到Serverconfiguration?请参考以下链接: Liberty Profile - Remote EJB Praveen做了一个勺子喂,谢谢他

    <feature>javaee-7.0</feature>
    <feature>ejbRemote-3.2</feature>
    <feature>jndi-1.0</feature>
    <feature>ejbLite-3.2</feature>
    <feature>localConnector-1.0</feature>
    <feature>servlet-3.1</feature>

在我在Liberty配置文件中部署的servlet中添加了以下6行代码

    Properties ejbProps = new Properties();
    ejbProps.put(Context.PROVIDER_URL, ejbUrl);
    InitialContext ffmContext = new InitialContext(ejbProps);
    Object remoteObject = ffmContext.lookup(ejbName);
    MyBeanRemote myBean = PortableRemoteObject.narrow(remoteObject, MyBean.class);
    myBean.callingMethod();

神奇的工作:MyBean方法被调用/调用。 注意:我生成了MyBean存根jar文件,并将其放在我的servlet中部署在wlp