就像标题上说的。我在EAR中有一些EJB,还有一个客户端jar为JSF应用程序提供远程方法(不同的服务器/机器)。客户端jar试图通过查找访问远程EJB。
这让我心碎了两天。正如标题所说..。
我知道来自过去的其他堆栈溢出问题,我知道以下资源:https://www.ibm.com/docs/en/was-liberty/core?topic=liberty-using-enterprise-javabeans-remote-interfaces
我试过上面提供的每一个组合,但没有joy。
我在启用javaee8特性时使用(wlp-javaee8.21.0.0.8),这使我所需要的所有其他功能(例如ejb-3.2、ejbRemote-3.2、jndi-1.0和其他几个)都启用了。
我有一个EAR my-ear,其中包含一个模块my -模块-1.0.4-SNAPSHOT.jar,其中包含我的bean。我正在使用gradle/gradle插件和IntelliJ。我正在使用客户机jar模块中的IntelliJ内部的测试来尝试访问远程bean。
我的myEAR部署良好,启动良好,应用程序显示在admincenter中运行。在messages.log中,我看到了我的EJB绑定。只举一个例子。
16/08/21 10:58:42:384 IST 00000022 i CNTR0167I:服务器正在My-模块1.0.4-SNAPSHOT.jar模块中绑定MyAdvanceBean企业bean的my.org.functiona.ejb.advance.MyAdvance接口。绑定位置是: ejb/my-ear/my-module-1.0.4-SNAPSHOT.jar/MyAdvanceBean#my.org.functiona.ejb.advance.MyAdvance 16/08/21 10:58:42:385 IST 00000022 com.ibm.ws.ejbcontainer.osgi.internal.NameSpaceBinderImpl i CNTR0167I:服务器在My-Mod-1.0.4SNAPSHOT.jar模块中绑定MyAdvanceBean企业bean的my.org.functiona.ejb.advance.MyAdvance接口。绑定位置为: com.ibm.ws.ejbcontainer.runtime.AbstractEJBRuntime 16/08/21 10:58:42:385 IST 00000022 my.org.functiona.ejb.advance.MyAdvance
I CNTR0167I:服务器在my应用程序的My-模块-1.0.4-SNAPSHOT.jar模块中绑定MyAdvanceBean企业bean的my.org.functiona.ejb.advance.MyAdvance接口。绑定位置是: java:global/my-ws-ear/my-module-1.0.4-SNAPSHOT.jar/MyAdvanceBean!my.org.functiona.ejb.advance.MyAdvance
这是我的相应接口:
package my.org.functiona.ejb.advance;
import javax.ejb.Remote;
@Remote
public interface MyAdvance {这是我相应的实现:
package my.org.functiona.ejb.advance;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
@Stateless(mappedName = "MyAdvance")
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public class MyAdvanceBean implements MyAdvance {就像我说的,这伤了我的心。我尝试了在(零碎的)文档和其他来源中提供的所有组合。我取得的最大进展是通过默认的InitialContext().lookup访问"corbaname::localhost:2809/NameService“。因此,至少我能够确认我可以通过NameService。但是,使用该上下文与messages.log中提供的名称或文档中的代码片段相结合的任何后续bean查找都会失败,只有下面的例外情况。
org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0是
javax.naming.NameNotFoundException根异常
对于InitialContext()查找,我在名称前面加上"corbaname::localhost:2809/NameService#“。
我试过了
可能还有其他几个
在上面的所有内容中,我用感叹号替换了#号。然后又经历了一次。我尝试了corbaloc::和corbaloc:iiop:用于上下文。没什么。
我不是网页开发专家,但这感觉很尝试和错误,我不觉得它应该是那样。我理解在websphere本体中,我可以识别管理控制台中的名称,但是我甚至不是特定的websphere专用的,而且even的行为方式也是一样的。
如果不需要从远程访问EJB,我想我忽略了一些基本的和愚蠢的东西,因为我缺乏经验。
有人指点过吗?非常感谢你花时间阅读这篇文章。
卡斯滕
编辑: server.xml
<server description="disbCoreServer">
<featureManager>
<feature>javaee-8.0</feature>
<feature>adminCenter-1.0</feature>
<feature>websocket-1.1</feature>
</featureManager>
<quickStartSecurity userName="admin" userPassword="carsten" />
<!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
<httpEndpoint id="defaultHttpEndpoint"
host="${hostname}"
httpPort="${default.http.port}"
httpsPort="${default.https.port}">
<accessLogging filepath="${com.ibm.ws.logging.log.directory}/accessLog.log" logFormat='%h %i %u %t "%r" %s %b %{R}W' />
<tcpOptions soReuseAddr="true" />
</httpEndpoint>
<include location="appConfXML/disb_core_jndi.xml"/>
<include location="appConfXML/disb_core_jdbc.xml"/>
<include location="appConfXML/disb_core_jms.xml"/>
<include location="appConfXML/disb_core_mail.xml"/>
</server>发布于 2021-09-16 11:26:41
通过FAT测试(remoteLookup)提供的示例运行得很好。我只是没有把我所有的鸭子连在一起。
我的场景是serverA托管EJB,serverB运行远程客户端调用serverA的EJB。
关于serverB的步骤如下:
没有属性的
使用上述查找远程上下文的Context remoteContext = (Context) initialContext.lookup("corbaname::remotehost:remotePort/NameService");:
使用
String lookupName = "ejb/global" + "/" + "MyAppName" + "/" + "MyModuleName" + "/" + jndiName; Object remoteObj = remoteContext.lookup(lookupName); return interfaceClass.cast(PortableRemoteObject.narrow(remoteObj, interfaceClass));
- "MyAppName" is my apps name, the name of the EAR in my case (without .jar)
- "MyModuleName" is the name of the EJB module within my EAR (without .jar)
- and jndiName is the bean name / fully qualified interface name separated by exclamation mark e.g. "MyBean!myorg.ejb.interfaces.MyBeanIfc"注意:当在同一台计算机(例如localhost)上运行serverA和serverB时,请确保它们不是在NameService的同一个端口上运行。
感谢所有想帮忙的人!
https://stackoverflow.com/questions/68802468
复制相似问题