users@glassfish.java.net

Local vs Remote GF JNDI Names

From: Garth Keesler <garthk_at_gdcjk.com>
Date: Sun, 21 Dec 2008 12:13:32 -0600

I'm a relative newbie exploring my first J2SE client accessing EJBs on a
remote GF server (but still local to my LAN). I have created an EE 5
module (not application) which deploys successfully to both the local GF
server as well as the remote GF server. The SE app runs successfully
against the local GF but not the remote, giving a naming exception when
looking up the JNDI name of the remote session bean. When I use "asadmin
list-jndi-entries" on the local GF, the remote session beans show up but
not when I use the same command on the remote server. The GF web console
on each GF server shows the module correctly deployed. Is there some
other magic I have to do to get the entries loaded into JNDI when
deploying from NetBeans v6.5 to a remote box? Again, all works fine when
running against the locally-installed GF server.

Most of the code is "borrowed" from various HowTos I've found on the web.

Thanx,
Garth

Below is the SE code I'm playing with:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package oescoretest;

import OESCore.EJBs.Vendor;
import OESCore.EJBs.VendorSessionRemote;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author garthk
 */
public class Main
  {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
      {
        try
          {
            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",
                    "gf1.gdkvpn.bogus");
            props.setProperty("org.omg.CORBA.ORBInitialPort", "3701");

            Context ic = new InitialContext(props);
            VendorSessionRemote vsb = (VendorSessionRemote)
ic.lookup("com.oes.session.VendorSessionRemote");
            // TODO code application logic here
            Vendor v = (Vendor) vsb.fetch("poe");
            if (v == null)
              {
                System.out.println("No such Vendor.");
              }
            else
              {
                System.out.println(v.getVendorname());
                System.out.println(v.getMailingaddress());
              }
          }
        catch (NamingException ex)
          {
            //Logger.getLogger(Main.class.getName()).log(Level.SEVERE,
null, ex);
            System.out.println(ex.getExplanation());
          }
      // TODO code application logic here
      }
  }