Monday November 14, 2005
Developing J2EE clients for Sun Application server In last post I wrote about EJB client for JBoss, today I would like to write introduction about J2EE clients for Sun Application server. You have two ways for devloping the client: using ACC or without it.
I guess that many users asks what this acronym stands for? ACC is Application Client Container. What is it? The Application client container includes a set of java classes, libraries and others files that are required for and distributed with Java clients programs that are executed in their JVM. The ACC manages the execution of J2EE app clients according to security, ... For instance, authentication techniques are provided by the client container and are note under control of the application client component. These security constraints are defined in deployment descriptor. I would like to develop this type of the client in next post.
Today, I will create simpler client that access EJB on remote server. This client doesn't use ACC. To access and EJB perform these steps:
InitialContext ctx = new InitialContext();
Object obj = ctx.lookup("beanName");
BeanHome home = (BeanHome)PortableRemoteObject.narrow(obj, BeanHome.class);
You can find beanName in server specific DD sun-ejb-jar.xml, the element jndi-name.
-Dorg.omg.CORBA.ORBInitialHost=ORBHostname -Dorg.omg.CORBA.ORBInitialPort=ORBPort
ORBHostname is the Application server hostname and ORBPort is port for ORB port, default 3700.
#!/bin/sh
JAVA_HOME="/usr/java/jdk1.5.0_02"
J2EE_LIB="/lib"
export JAVA_HOME
CLASS_PATH="$J2EE_LIB/j2ee.jar:$J2EE_LIB/appserv-rt.jar:MyClient.jar"
ARGS="-Dorg.omg.CORBA.ORBInitialHost=Hostname -Dorg.omg.CORBA.ORBInitialPort=3700"
$JAVA_HOME/bin/java $ARGS -cp $CLASS_PATH pkg.Main
exit 0