[英]How to access EJB deployed to GlassFish 2 server from web app deployed to JBoss EAP 6?
We're migrating our web app from GF 2.1.1 (Java 6) to JBoss EAP 6.3.0 (Java 7) and need to use one EJB from GF for some time until it will migrate to JBoss too. 我们正在将Web应用程序从GF 2.1.1(Java 6)迁移到JBoss EAP 6.3.0(Java 7),并且需要一段时间使用GF中的一个EJB,直到它也迁移到JBoss。
1 - Previously we just used GF's External JNDI resource to connect to this EJB: 1-以前我们只是使用GF的External JNDI资源连接到此EJB:
<external-jndi-resource enabled="true"
factory-class="com.sun.enterprise.naming.SerialInitContextFactory"
jndi-lookup-name="ejb/NameOfEJB" jndi-name="ejb/NameOfEJB"
object-type="user" res-type="name.of.ejb.interfaces.NameOfEJB">
<property name="org.omg.CORBA.ORBInitialPort" value="3700"/>
<property name="org.omg.CORBA.ORBInitialHost" value="hostname.of.ejb"/>
</external-jndi-resource>
I couldn't find anything similar to this on JB yet. 我在JB上找不到与此类似的东西。
2 - I tried to reach this EJB through the code using GF's implementation: 2-我尝试使用GF的实现通过代码访问此EJB:
Properties props = new Properties();
props.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
props.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
props.setProperty("org.omg.CORBA.ORBInitialHost", zoneHost);
props.setProperty("org.omg.CORBA.ORBInitialPort", zonePort);
InitialContext ic = new InitialContext(props);
Object obj = ic.lookup("ejb/NameOfEJB");
But I couldn't get rid of all the Exceptions, that JB started throwing when I tried to add GF's libs (appserv-rt.jar...) needed to use this approach. 但是我无法摆脱所有异常,当我尝试添加使用这种方法所需的GF的libs(appserv-rt.jar ...)时,JB开始抛出异常。
3 - I also tried to reach this EJB through the code using JB's implementation: 3-我还尝试使用JB的实现通过代码来访问此EJB:
Properties props = new Properties();
props.setProperty("java.naming.factory.initial", "org.jboss.naming.remote.client.InitialContextFactory");
props.setProperty("java.naming.factory.url.pkgs", "org.jboss.ejb.client.naming");
props.put("jboss.naming.client.ejb.context", true);
props.setProperty(Context.PROVIDER_URL, "remote://" + zoneHost+ ":" + zonePort);
// also tried to add Context.SECURITY_PRINCIPAL and CREDENTIALS properties, but they didn't change anything
InitialContext ic = new InitialContext(props);
Object obj = ic.lookup("ejb/NameOfEJB");
Which resulted in timeout after 5 seconds. 5秒后导致超时。
Can something like (1) be done in JBoss? 可以在JBoss中完成类似(1)的操作吗? That would be the best option.
那将是最好的选择。
Is GF approach (2) even possible from JBoss? JBoss甚至可以使用GF方法(2)吗?
If I need to use JB approach (3), then what am I doing wrong? 如果我需要使用JB方法(3),那我在做什么错呢?
Your first 2 approaches are wrong, since they're Glassfish dependent, and you wish to connect from JBoss to Glassfish. 您的前两种方法是错误的,因为它们依赖于Glassfish,并且您希望从JBoss连接到 Glassfish。
The last approach seems to be somewhat correct, according to the documentation. 根据文档 ,最后一种方法似乎有些正确。
I would first check out that the host/port is accessible and also turn on all possible logging to see what's going on. 我首先要检查主机/端口是否可访问,还要打开所有可能的日志记录以查看发生了什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.