Standalone IIOP Clients with GlassFish

I often get asked how a standalone client can be used to connect to EJBs deployed on GlassFish or Sun Appserver 8.x. Here are the choices:

  • Set system properties org.omg.CORBA\*
    You can do this either in your application code or as jvm start parameters
    System.setProperty("org.omg.CORBA.ORBInitialPort",""); System.setProperty("org.omg.CORBA.ORBInitialHost","");
    or set it as JVM property like this: java -Dorg.omg.CORBA.ORBInitialHost=host -Dorg.omg.CORBA.ORBInitialPort=3700

  • Set System property com.sun.appserv.iiop.endpoints:
    You can also use the JVM system property com.sun.appserv.iiop.endpoint=host:port to specify the endpoint address. Also this property supports multiple endpoints to support load balancing. For example setting java -Dcom.sun.appserv.iiop.endpoints=host1:port1,host2:port2 ... specifies host2 as failover endpoint if host1 crashes.

  • Set InitialContext Properties
    The last approach that may be used is to set ORBInitialHost/ORBInitialPort as properties for the InitialContext like this:
    Properties p = new Properties();
    p.put("org.omg.CORBA.ORBInitialHost","localhost");
    p.put("org.omg.CORBA.ORBInitialPort","33700");
    InitialContext ctx = new InitialContext(p);
    //... do the lookups...
    
    To make the standalone client run you also have to setup your classpath correct. You have to put appserv-rt.jar, appserv-admin.jar and javaee.jar in your client classpath in addition to the EJB interfaces. Additional parameters are not needed as more properties are picked from the jndi.properties file that is contained in above jars. More information can also be found in the GlassFish EJB FAQ: https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html
  • Kommentare:

    Senden Sie einen Kommentar:
    Kommentare sind ausgeschaltet.
    About

    Daniel Adelhardt

    Search

    Archives
    « April 2014
    MoDiMiDoFrSaSo
     
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
        
           
    Heute