Reputation: 5915
I was reading about "Portable Global JNDI names" in several articles, here and there for example, but I was unable to understand whether this syntax only applies to inbound machine lookups (or maybe inbound server lookup if the server is clustered).
I.e, does it only try to solve the problem of lookups between modules and apps on the same machine/server?
Because I keep seeing examples referencing to this feature and using @Remote
which I would imagine can very well occur cross-machine/server.
If it indeed only resolves internal lookups to machine/server I'd appreciate it if someone could point me to the right direction with respect to how to use it with @Remote
between servers (I'm guessing somewhere I need to prefix the host name).
Thanks,
Ittai
Upvotes: 1
Views: 959
Reputation: 437
In that case you can use mention it in descriptor file then you can inject it using @EJB
@EJB(name="fooejbref")
private FooRemote fooRemote;
Within sun-web.xml :
<ejb-ref>
<ejb-ref-name>fooejbref</ejb-ref-name>
<jndi-name>corbaname:iiop:host2:3700#Foo</jndi-name>
</ejb-ref>
for details please please look this url http://glassfish.java.net/javaee5/ejb/EJB_FAQ.html#StandaloneRemoteEJB
Upvotes: 1
Reputation: 437
You can call EJB component from another machine that's why @Remote anotation exists.Like
String host = "10.1.1.111";
String port = "3700";
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("org.omg.CORBA.ORBInitialHost", host);
props.setProperty("org.omg.CORBA.ORBInitialPort", port);
InitialContext ctx = new InitialContext(props);
TestService ejb = (TestService)ctx.lookup("java:global/XXX/XXX/TestEntityFacade!com.test.service.TestService");
ejb.findAll();
Upvotes: 1