This discussion is archived
2 Replies Latest reply: Apr 12, 2011 2:25 AM by mauric RSS

Glassfish 3.1 and initial context from a client.

mauric Newbie
Currently Being Moderated
Good morning to all,

I'm quite desperate for a problem that, as far as I've read, it's quite common...anyway, I can't find a solution.

Well, I've developed a very simple EJB which receives a String and returns it. Just a "trip call".

Now, in Netbeans 6.9.1, on the same machine where GF 3.1 is running on, i use this code to setup InitialContext:
 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");
          // optional.  Defaults to localhost.  Only needed if web server is running
          // on a different host than the appserver
          props.setProperty("org.omg.CORBA.ORBInitialHost", "10.187.90.253");
          // optional.  Defaults to 3700.  Only needed if target orb port is not 3700.
          props.setProperty("org.omg.CORBA.ORBInitialPort", "7001");
This code works ok as long as I run it within NetBeans. If I just copy generated "dist" folder with "lib" folder, and try to exec it from a command shell on another machine,
I get an exception saying that "com.sun.enterprise.naming.SerialInitContextFactory" in not found.

I made gf-client.jar and appserver-rt.jar available to client, but no luck. By the way, appserver-rt.jar is empty (or, well, contains some stuff but no java class files).

Can anybody explain me what's wrong and/or which jars are really required ? On the web, I've found quite anything... like copying all GF jar on client classpath or installa GF on each cllient. These solutions, at least for me, are totally impractical, so I really need to understand how operate. On documentation it's also said to use default InitialContext no-args constructor, but in this case how may define bootstrap properties ? The remote server IP may change or may be NATted, so besides to properly configurate ORB listener, I'd like to programmatically set these properties.

Thanks in advance.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points