简体   繁体   中英

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.

1 - Previously we just used GF's External JNDI resource to connect to this 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.

2 - I tried to reach this EJB through the code using GF's implementation:

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.

3 - I also tried to reach this EJB through the code using JB's implementation:

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.

Can something like (1) be done in JBoss? That would be the best option.

Is GF approach (2) even possible from JBoss?

If I need to use JB approach (3), then what am I doing wrong?

Your first 2 approaches are wrong, since they're Glassfish dependent, and you wish to connect from JBoss to 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM