英文:
How to make remote EJB call from thin client to WebSphere Liberty
问题
以下是翻译好的内容:
我正试图从一个非常轻量级的客户端向WebSphere Liberty 20.0.0.10(JDK 8)进行远程 EJB 3 调用。该客户端并未在 EJB 容器中运行。我在 Google 上找到了这个页面,并尝试遵循其中的说明:
https://www.ibm.com/support/knowledgecenter/SSD28V_liberty/com.ibm.websphere.wlp.core.doc/ae/twlp_ejb_remote.html
根据服务器日志,该 EJB 绑定到了这个地址:
CNTR0167I: 服务器正在绑定 codeserver 应用模块中 DW_CS_LoggingRemoteServicesBean 企业 bean 的 fi.datawell.cs.ejb.logging.boundary.DW_CS_LoggingServices 接口。绑定位置为:java:global/codeserver/DW_CS_LoggingRemoteServicesBean!fi.datawell.cs.ejb.logging.boundary.DW_CS_LoggingServices
(codeserver 是应用的名称,且只有一个包含 EJB 的 war 模块)
我可以在本地调用它而没有问题。我尝试用以下字符串来远程查找它:
corbaname::localhost:12809#ejb/global/codeserver/DW_CS_LoggingRemoteServicesBean!fi\.datawell\.cs\.ejb\.logging\.boundary\.DW_CS_LoggingServices
(IIOP 服务位于端口 12809)
然而,不知何故,我在日志中得到了这个错误,尽管它没有在应用程序中引发异常:
WARNING: "IOP00410201: (COMM_FAILURE) 连接失败:socketType: IIOP_CLEAR_TEXT;hostname: localhost;port: 0"
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2200)
at ...
该地址似乎是正确的,因为如果我更改端口,我会得到“连接被拒绝”,如果我更改 bean 名称,我会得到 NameNotFoundException。
我得到了一个 com.sun.corba.se.impl.corba.CORBAObjectImpl
的实例作为响应,但当我使用 PortableRemoteObject.narrow()
方法时,我得到了一个空值而没有任何异常。现在我想知道我做错了什么。即使这是 EJB 3 应用程序,我是否需要某种 EJB 存根?
补充说明:实际上,我们正在从传统的 WebSphere 迁移到 WebSphere Liberty,我认为我们可以摆脱运行 createEJBStubs 的步骤,因为它很慢(使用 maven 插件)并且需要 WAS 传统安装(在 Mac 上不可用)。现在我尝试了一下 createEJBStubs,进展有了一些。首先,我必须将 com.ibm.websphere.javaee.ejb.3.2_1.0.45.jar
添加到类路径中。在这之后,事情稍微有所进展。我可以获取到 EJB,但第一次尝试使用它时会失败,出现了一个熟悉的异常:
javax.ejb.EJBException: 嵌套异常为:java.rmi.MarshalException:CORBA COMM_FAILURE 1398079689 No;嵌套异常为:
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
at ...
现在我不知道接下来该尝试什么。每当检索到 EJB 时,仍然会在日志中出现相同的异常,但在这种情况下,它似乎被静默地消耗掉了。我不知道为什么异常中会有端口 0...
英文:
I'm trying to make a remote EJB 3 call from a thin client to WebSphere Liberty 20.0.0.10 (JDK 8). The client is not running in an EJB container. I googled this page and tried to follow the instructions:
https://www.ibm.com/support/knowledgecenter/SSD28V_liberty/com.ibm.websphere.wlp.core.doc/ae/twlp_ejb_remote.html
According to the server log, the EJB is bound to this address:
CNTR0167I: The server is binding the fi.datawell.cs.ejb.logging.boundary.DW_CS_LoggingServices interface of the DW_CS_LoggingRemoteServicesBean enterprise bean in the codeserver.war module of the codeserver application. The binding location is: java:global/codeserver/DW_CS_LoggingRemoteServicesBean!fi.datawell.cs.ejb.logging.boundary.DW_CS_LoggingServices
(codeserver is the name of the application, and there's only a single war module which contains the EJBs)
I can call it locally without problems. I try to look it up remotely with this string:
corbaname::localhost:12809#ejb/global/codeserver/DW_CS_LoggingRemoteServicesBean!fi\.datawell\.cs\.ejb\.logging\.boundary\.DW_CS_LoggingServices
(The IIOP service is in port 12809)
Somehow I get this error in the log, although it doesn't cause an exception in the application.
WARNING: "IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: localhost; port: 0"
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2200)
at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2221)
at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:223)
at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:236)
at com.sun.corba.se.impl.transport.SocketOrChannelContactInfoImpl.createConnection(SocketOrChannelContactInfoImpl.java:119)
at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(CorbaClientRequestDispatcherImpl.java:187)
at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.request(CorbaClientDelegateImpl.java:137)
at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.is_a(CorbaClientDelegateImpl.java:229)
at org.omg.CORBA.portable.ObjectImpl._is_a(ObjectImpl.java:130)
at org.omg.CosNaming.NamingContextHelper.narrow(NamingContextHelper.java:69)
at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:504)
at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:555)
at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:205)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at fi.datawell.cs.ejb.DW_CS_EjbFactory.lookupService(DW_CS_EjbFactory.java:91)
at fi.datawell.cs.ejb.DW_CS_EjbFactory.lookupLoggingRemoteServicesEJB(DW_CS_EjbFactory.java:284)
at fi.datawell.cs.application.clients.versionloader.DW_CS_VersionLoaderWorker.fetchClientServices(DW_CS_VersionLoaderWorker.java:983)
at fi.datawell.cs.application.clients.versionloader.DW_CS_VersionLoader.initialize(DW_CS_VersionLoader.java:114)
at fi.datawell.cs.application.clients.versionloader.DW_CS_VersionLoader.main(DW_CS_VersionLoader.java:252)
Caused by: java.net.BindException: Cannot assign requested address: connect
at sun.nio.ch.Net.connect0(Native Method)
at sun.nio.ch.Net.connect(Net.java:454)
at sun.nio.ch.Net.connect(Net.java:446)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:648)
at java.nio.channels.SocketChannel.open(SocketChannel.java:189)
at com.sun.corba.se.impl.transport.DefaultSocketFactoryImpl.createSocket(DefaultSocketFactoryImpl.java:95)
at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:207)
... 16 more
This address seems to be correct, because if I change the port, I get "connection refused" and if I change the bean name, I get NameNotFoundException.
I get an instance of com.sun.corba.se.impl.corba.CORBAObjectImpl
as response, but when I use PortableRemoteObject.narrow()
method, I get null without any exception. Now I wonder what I'm doing wrong. Do I need some kind of EJB stubs although this is EJB 3 application?
Addendum: Actually we are doing a migration from WebSphere traditional to WebSphere Liberty and I thought we could get rid of running createEJBStubs, because it is slow (using maven plugin) and requires WAS traditional installation (which isn't available for Mac). Now I tried with createEJBStubs and got a bit further. First I had to add com.ibm.websphere.javaee.ejb.3.2_1.0.45.jar
to classpath. After that things get a bit further. I can fetch the EJB, but the first attempt to use it fails with a familiar exception:
javax.ejb.EJBException: nested exception is: java.rmi.MarshalException: CORBA COMM_FAILURE 1398079689 No; nested exception is:
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
at fi.datawell.cs.ejb.logging.boundary._DW_CS_LoggingServices_Stub.log(_DW_CS_LoggingServices_Stub.java:1101)
at fi.datawell.cs.application.clients.core.DW_CS_BaseWorker.writeCodeServerLog(DW_CS_BaseWorker.java:66)
at fi.datawell.cs.application.clients.versionloader.DW_CS_VersionLoader.initialize(DW_CS_VersionLoader.java:120)
at fi.datawell.cs.application.clients.versionloader.DW_CS_VersionLoader.main(DW_CS_VersionLoader.java:252)
Caused by: java.rmi.MarshalException: CORBA COMM_FAILURE 1398079689 No; nested exception is:
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
at com.sun.corba.se.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:219)
at javax.rmi.CORBA.Util.mapSystemException(Util.java:95)
at fi.datawell.cs.ejb.logging.boundary._DW_CS_LoggingServices_Stub.log(_DW_CS_LoggingServices_Stub.java:1)
... 3 more
Caused by: org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2200)
at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2221)
at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:223)
at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:236)
at com.sun.corba.se.impl.transport.SocketOrChannelContactInfoImpl.createConnection(SocketOrChannelContactInfoImpl.java:119)
at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(CorbaClientRequestDispatcherImpl.java:187)
at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.request(CorbaClientDelegateImpl.java:137)
at org.omg.CORBA.portable.ObjectImpl._request(ObjectImpl.java:449)
at fi.datawell.cs.ejb.logging.boundary._DW_CS_LoggingServices_Stub.log(_DW_CS_LoggingServices_Stub.java)
... 3 more
Caused by: java.net.BindException: Cannot assign requested address: connect
at sun.nio.ch.Net.connect0(Native Method)
at sun.nio.ch.Net.connect(Net.java:454)
at sun.nio.ch.Net.connect(Net.java:446)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:648)
at java.nio.channels.SocketChannel.open(SocketChannel.java:189)
at com.sun.corba.se.impl.transport.DefaultSocketFactoryImpl.createSocket(DefaultSocketFactoryImpl.java:95)
at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:207)
... 9 more
Now I don't know what to try next. The same exception still appears on log whenever the EJB is retrieved, but in that situation it seems to be silently consumed. I wonder why there is port 0 in the exception...
答案1
得分: 1
WebSphere Liberty没有提供EJB的轻量级客户端,但是您可以使用WebSphere传统的轻量级客户端来访问WebSphere Liberty服务器:
链接:https://www.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.nd.multiplatform.doc/ae/tcli_ejbthinclient.html
对于轻量级客户端,所有EJB远程接口都需要一个存根(Stub),无论是使用2.x还是3.x API。对于EJB 2.x,您可以使用带有-iiop
选项的RMIC
。对于EJB 3.x(本文中使用的版本),您需要使用WebSphere传统提供的createEJBStubs
命令:
链接:https://www.ibm.com/support/knowledgecenter/en/SSEQTP_8.5.5/com.ibm.websphere.base.doc/ae/rejb_3stubscmd.html
createEJBStubs
也可用于EJB 2.x远程接口。
请注意,在启用了ejbRemote-3.2
特性的WebSphere服务器进程中,会为您生成存根(Stub),或者在应用程序客户端进程(即厚客户端)中生成。有关应用程序客户端的更多信息,请参见此处:
链接:https://www.ibm.com/support/knowledgecenter/SSEQTP_liberty/com.ibm.websphere.wlp.doc/ae/twlp_setup_prepareappclient.html
由于您正在收到CORBAObjectImpl
,并且narrow
方法无法正常工作,这至少部分说明问题是缺少存根(Stub)类所致。
英文:
WebSphere Liberty does not provide an EJB thin client, however, you may use the WebSphere traditional thin client to access a WebSphere Liberty server:
For a thin client, all EJB remote interfaces require a Stub, whether using the 2.x or 3.x APIs. For EJB 2.x, you could use RMIC
with the -iiop
option. For EJB 3.x (that is being used here), you need to use the createEJBStubs
command provided by WebSphere traditional :
createEJBStubs
may also be used for EJB 2.x remote interfaces as well.
Note that a Stub is generated for you in a WebSphere server process that has the ejbRemote-3.2
feature enabled or in an application client process (i.e. thick client). More information about the application client is here:
Since you are receiving a CORBAObjectImpl
, and the narrow does not work, it would seem that at least part of the problem is the lack of Stub classes.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论