1

I have two laptops. Both are connected to the Internet via my home wi-fi router.

laptop1: testing Java Enterprise Edition 7 applications, using NetBeans 8 and GlassFish 4

laptop2: testing Java Standard Edition 7 applications, using Eclipse Mars

Here is what I did on laptop1:

  1. Packaged a simple EJB component and a library containing the EJB's remote interface into an EAR.

  2. Deployed it successfully on GlassFish.

  3. Packaged an enterprise application client and the same library containing the EJB's remote interface into a module and deployed it separately on GlassFish.

  4. Both applications (EAR and client module) were running fine and the client was able to invoke the ejb component's method using dependency injection (@EJB).

Here is what I am facing problems with while doing something involving both laptop1 and laptop2:

I am trying to create a stand-alone non-EE client on laptop2 in order to invoke methods on the remote EJB component residing on laptop1. I am following this document https://glassfish.java.net/docs/4.0/application-development-guide.pdf

The steps written in that document are below. Please see my questions embedded below.

STEP1

InitialContext ctx = new InitialContext();

BeanRemote bean = (BeanRemote) ctx.lookup("com.acme.BeanRemote");

It does not look like JNDI to me. Where is java:global in it?

STEP2

Copy the as-install/lib/gf-client.jar file to the client machine and include it in the classpath on the client side. How do I do it and where do I find the classpath on the client side?

If there is no GlassFish Server installation on the client machine (duh!), you must also copy the as-install/modules directory to the client machine and maintain its directory structure relative to the as-install/lib/gf-client.jar file. Relative in the classpath?

STEP3

Set the following system properties for the JVM startup options:

-Dorg.omg.CORBA.ORBInitialHost=${ORBhost}

-Dorg.omg.CORBA.ORBInitialPort=${ORBport}

Here ORBhost is the GlassFish Server hostname and ORBport is the ORB port number (default is 3700 for the default server instance, named server).

How do I set the above startup options for the JVM on the client side?

STEP4

Make sure the etc/hosts file on the client machine maps the GlassFish Server hostname and external IP address. In this file on each laptop do I need to tag a fully qualified domain to the computer name and place it next to the IP assigned by the wi-fi network?

softwarelover
  • 1,009
  • 1
  • 10
  • 22
  • You'd rather wrap your EJBs behind we a web service, and access it using an HTTP api, shouldn't you... – Patrice Gagnon Mar 01 '16 at 19:07
  • The problem is accessing remotely, not the nature of the EJB. – softwarelover Mar 01 '16 at 19:47
  • What's wrong with this site? Not a single, useful answer. I went through a lot, summing up the lines here, meticulously.\ – softwarelover Mar 01 '16 at 23:10
  • That was my point. It tells you a bit how much people care about EJBs, and especially accessing them remotely. I was suggesting a more common way to access a server functionality. Granted you have EJBs, they work fine, accessing them via some HTTP based web service will be simpler. – Patrice Gagnon Mar 03 '16 at 13:53
  • Thanks, Patrice, for returning to my post. Yes, I see your point now. – softwarelover Mar 04 '16 at 06:08

1 Answers1

0

try this

String ejbConnectionName = String.format("ejb:%s/%s!%s", appModuleName, beanName, remoteBeanName);              
BeanRemote bean = (BeanRemote) context.lookup(ejbConnectionName);
Lasha Gureshidze
  • 147
  • 2
  • 10