问题描述
我正在尝试从瘦客户机向WebSphere Liberty 20.0.0.10(JDK 8)进行远程EJB 3调用。客户端不在EJB容器中运行。我在此页面上进行了搜索,并尝试按照说明进行操作: https://www.ibm.com/support/knowledgecenter/SSD28V_liberty/com.ibm.websphere.wlp.core.doc/ae/twlp_ejb_remote.html
根据服务器日志,EJB绑定到以下地址:
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
(代码服务器是应用程序的名称,只有一个包含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) 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
该地址似乎是正确的,因为如果更改端口,则会收到“连接被拒绝”的信息,如果更改Bean名称,则会出现NameNotFoundException。
我得到一个com.sun.corba.se.impl.corba.CORBAObjectImpl
的实例作为响应,但是当我使用PortableRemoteObject.narrow()
方法时,我得到的null毫无例外。现在我想知道我在做什么错。尽管这是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: 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
现在我不知道下一步该怎么做。每当检索到EJB时,相同的异常仍会出现在日志中,但是在那种情况下,它似乎被静默消耗了。我想知道为什么例外中有端口0 ...
解决方法
WebSphere Liberty不提供EJB瘦客户端,但是,您可以使用WebSphere传统瘦客户端来访问WebSphere Liberty服务器:
对于瘦客户端,无论使用2.x还是3.x API,所有EJB远程接口都需要一个Stub。对于EJB 2.x,可以将RMIC
与-iiop
选项一起使用。对于EJB 3.x(在此使用),您需要使用WebSphere传统提供的createEJBStubs
命令:
createEJBStubs
也可以用于EJB 2.x远程接口。
请注意,在启用了ejbRemote-3.2
功能的WebSphere服务器进程中或在应用程序客户端进程(即胖客户端)中会为您生成一个Stub。有关应用程序客户端的更多信息,请参见:
由于您收到的是CORBAObjectImpl
,并且缩小方法不起作用,因此看来至少部分原因是缺少Stub类。