Child pages
  • Creating deployment plans for Java EE application clients
Skip to end of metadata
Go to start of metadata

Java EE Application Client deployment plan

Java EE application client modules run in client container and also have access to server environment. Usually, Java EE client applications are created to administer the running enterprise applications in the server. Client modules run in a separate JVM and connect to enterprise application resources but have access to all the application resources in standard Java EE way.

The Java EE client module requires application-client.xml as deployment descriptor and geronimo-application-client.xml as deployment plan. In the application-client.xml, the required ejb names, security role names, resources names etc., are declared while in geronimo-application-client.xml, the declared names are mapped to actual resources in server.

The following is the deployment descriptor of the Java EE application client module that looks up an ejb and calls a method on it. The ejb converts the Indian Rupess (Rs.) into American Dollars ($). The client sends a double value which is Indian Rupees to ejb. The ejb returns equivalent American Dollars as double value.

<?xml version="1.0" encoding="UTF-8"?>

<application-client xmlns="" 


The default namespace of the above XML document is The XML elements that do not have a namespace prefix belong to the default namespace. Hence, in the above XML document, all the XML elements belong to the default namespace.

The application client declares the ejb name ejb/Converter through <ejb-ref>> .. </ejb-ref> elements.

Following is the corresponding deployment plan of the Java EE client module.

<?xml version="1.0" encoding="UTF-8"?>

<application-client xmlns=""

The default namespace of the above XML document is The XML elements that do not have a namespace prefix belong to the default namespace. Hence, in the above XML document, <application-client>, <ejb-ref> and <ref-name> elements belong to the default namespace.

Observe the various xml elements and schemas to which they belong. The plan defines the client environment and the server environment configurations. The server environment configuration runs in the server where as the client environment configuration runs in the client JVM. In the above plan, the ejb name ejb/Converter is mapped to ConverterBean ejb in the ConverterEAR.

The below is the client code that looks up the ejb and calls the method on it.
package examples.appclient.client;
import javax.naming.Context;
import javax.naming.InitialContext;
import examples.appclient.Converter;

public class ConverterClient {

 //The remote interface of the ConverterBean packaged with the
 //Java EE client jar
   private static Converter converter;

   private static double amount = 50;
   public static void main(String[] args) {
    amount = Double.parseDouble(args[0]);

    public static void doConversion() {
     try {
        Context context = new InitialContext();
        converter = (Converter) 
        double dollars = converter.getDollars(amount);
        System.out.println("Rs " + amount + " is " + dollars + " Dollars.");
        } catch (Exception ex) {
            System.err.println("Caught an unexpected exception!");

The META-INF/MANIFEST.MF file should contain the following entry for the client to run.

Manifest-Version: 1.0
Main-Class: examples.appclient.client.ConverterClient

Do not forget to insert a new line after the Main-Class: entry in the MANIFEST.MF file.

The Java EE client is created by packaging META-INF/application-client.xml, META-INF/geronimo-application-client.xml, ConverterClient.class, Converter.class and META-INF/MANIFEST.MF files into a jar file.

The following command illustrates the packaging.

C:\temp\ConverterEJBClient>jar -cvf ConverterEJBClient.jar *
added manifest
adding: examples/(in = 0) (out= 0)(stored 0%)
adding: examples/appclient/(in = 0) (out= 0)(stored 0%)
adding: examples/appclient/client/(in = 0) (out= 0)(stored 0%)
adding: examples/appclient/client/ConverterClient.class(in = 1716) (out= 936)(deflated 45%)
adding: examples/appclient/Converter.class(in = 146) (out= 131)(deflated 10%)
adding: META-INF/application-client.xml(in = 510) (out= 252)(deflated 50%)
adding: META-INF/geronimo-application-client.xml(in = 2049) (out= 474)(deflated 76%)
ignoring entry META-INF/MANIFEST.MF

The following commands illustrates the deployment and running of the client module.

C:\\Geronimo-2.1\bin>deploy.bat --user system --password manager deploy C:\temp\ConverterEJBClient.jar
Using GERONIMO_BASE:   C:\Geronimo-2.1
Using GERONIMO_HOME:   C:\Geronimo-2.1
Using GERONIMO_TMPDIR: var\temp
Using JRE_HOME:        C:\JDK\jre
    Deployed Converter/Converter-app-client-server/3.0/jar

C:\Geronimo-2.1\bin>java -Djava.endorsed.dirs="C:\Geronimo-2.1\lib\endorsed" -jar
              C:\Geronimo-2.1\bin\client.jar Converter/Converter-app-client/3.0/jar 4000

Rs 4000.0 is 100.0 Dollars.
  • No labels