EJB Deployment   «Prev  Next»

Lesson 7 Running the client
Objective Execute the client so that it accesses the deployed Hello bean.

Run and Execute Client

In the previous lesson, the Hello bean was deployed on the J2EE platform. It is now ready for access by clients.

Client jar file

At deployment time, the J2EE platform stores a remote reference (the proxy) in JNDI and then puts the client support files in a jar file that is written to the hello directory.
The client will use the stub class in the jar file to connect to the bean.
The jar file for the HelloApp has the name HelloAppClient.jar, and this was returned by the deploytool during deployment.

Running the client

The client is run with a script file called runClient as follows:
Unix (runClient.sh):
#!/bin/sh

J2EE_HOME=<j2ee-installation-location>

CPATH=$J2EE_HOME/lib/j2ee.jar:HelloAppClient.jar:. 

java  -classpath "$CPATH" HelloAppClient

Windows (runClient.bat):
set J2EE_HOME=  <j2ee-installation-location>
set CPATH=.;%J2EE_HOME%\xf5 ib\j2ee.jar;HelloAppClient.jar

java -classpath "%CPATH%" HelloAppClient

When running the client with the script file above, the output will be as follows:
Looking up the home object
Creating the bean instance
Calling the business methods
calling String sayHello()
HelloException while invoking sayHello()
name is null
calling void sayHello("Mickey")
got Hello Mickey 
Removing the bean

Run Client Session Bean - Exercise

Verify that the output shown above is produced by completing the following exercise. Run Client Session Bean - Exercise