EJB, removal between two application servers (glass fish)


I want to have a bean Fooin the host A, which is entered using the annotation @EJBfor the bean Barin the host B.
Both of these nodes are separate standalone instances Glassfish-v3.
When reading the documents, GlassfishI found a lot of information, some of them sounded a bit contradictory.
I realized that every bean has a global jndi assigned to it and understands how it is built. What is the syntax for portable JNDI global names? . I also realized that the declaration Fooin Barshould be something like this (assuming it FooRemoteis a remote business interface Fooand fooejbis its module):, @EJB(lookup=java:global/fooejb/FooRemote) FooRemote foothis is based on this .
I can't figure out where I say host Aand host Bto get to know each other.
I saw many examples for application clients and application servers, but I could not find an example for such a scenario.
In this issue Set sun-web.xmland Global-JNDI, but I think it's not EJB3.1 (since it is not Portable JNDI), and I do not understand where it should be this sun-web.xml(I'd like to avoid it if you can).
This mainly differs in two ways:

  • There is no option -Dorg.omg.CORBA.ORBInitialHost = param (as far as I can see)
  • Any solution should, of course, allow the inclusion of a third host C, with which they interact both Afor and Bfor different purposes.

, - , , , .
BTW, .. IP- .

Edit:
, , , .. , A1 A2, , B A1, A2

Edit2:
, ejb 3.1, , jndi. , ejb 3.1, , , 3.0 Global jndi.
, , "" jndi remote beans.
, -.

,

+3
3

We use remote EJBs and work great.

First, you'll need an EJB on "Host A", which implements an interface whose class is present on both hosts.

//For host A + B
public interface FooClass {
    public void theMethod();
}

//Only for host A
@Stateless
public class FooClassImpl implements FooClass {
    public void theMethod(){//Code goes here}
}

Then you need to create (on host B) the glassfish-web.xml file in your WEB-INF directory, where you specify where the remote EJB is located:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app error-url="">
  <ejb-ref>
    <ejb-ref-name>RemoteEJBName</ejb-ref-name>
    <jndi-name>corbaname:iiop:<servername or IP>:3700#java:global/<projectname>/FooClassImpl!com.test.foo.FooClass</jndi-name>
  </ejb-ref>
</glassfish-web-app>

At the injection point on host B, you need to enter EJB as follows:

@EJB(name = "RemoteEJBName")
private FooClass theFooClassInstance;

Hope this helps.

0
source

All Articles