Deploying and running Java EE application client has been edited by Ying Tang (Feb 26, 2009).

(View changes)


You can create an application client that runs in the Apache Geronimo application client container rather than running in your local Java environment. The main purpose of the Geronimo client application container is to provide a standard set of services to a client program without forcing the client application to specify a list of dependencies - in other words ease-of-development. The client code can lookup Geronimo components such as resources, EJBs, and connectors via standard JNDI lookup. This example creates the simplest application client that can talk to a Geronimo server and place a message in the Geronimo console.

  1. Create a client jar file for a simple example with these files. The client will write a message "CLIENT RUNNING..." on the Geronimo console: client/
    package client;
    public class MainClient {
         * @param args ignored
        public static void main(String[] args){
            System.out.println ("CLIENT RUNNING...");  
  2. Create an application client deployment descriptor that provides the client display name: META-INF/application-client.xml
    <?xml version="1.0"?>
    <application-client xmlns="" xmlns:xsi=""
     xsi:schemaLocation=" []" version="1.4">
        <display-name>EXAMPLE Client</display-name>
  3. Create a Geronimo application client deployment plan that describes the deployment moduleId and types: META-INF/geronimo-application-client.xml You need to define two modules, one for client side and one for server side. EXAMPLEClientServer is the component that always its going to be running on the server, and EXAMPLEClient is the component that you are going to run on the client from client.jar.
    <?xml version="1.0"?>
    <application-client xmlns="" xmlns:dep="">
  4. Create a manifest that tells the Java jar util which class to run first. META-INF/MANIFEST.MF
    Manifest-Version: 1.0
    Main-Class: client.MainClient
    \# blank line

    MANIFEST must contain the Main-Class and blank line at the end of the file.

  5. Create a bat file that packages the client jar, undeploys any older versions of the client/server apps, and deploys the client application. This bat file creates the J2EE application client jar file (Here is is named app_client.jar.) and associated files from an application bin folder (in this case D:\workspace2\GERONIMO_APPLICATION\bin). Run java client/ to create a class file. The jar command -M paramenter indicates the jar file must be created using a MANIFEST.MF file. Verify that this is correct after create jar file.
jar -cfM  app_client.jar -C D:\workspace2\GERONIMO_APPLICATION\bin .
java -jar %GERONIMO_HOME%/bin/deployer.jar --user system --password manager --host localhost undeploy JEE5/EXAMPLEClient/2.1/car
java -jar %GERONIMO_HOME%/bin/deployer.jar --user system --password manager --host localhost undeploy JEE5/EXAMPLEClientServer/2.1/car
java -jar %GERONIMO_HOME%/bin/deployer.jar --user system --password manager deploy app_client.jar

After deploy, you will see the two components into Geronimo Web Console: Applications -> App Clients:

JEE5/EXAMPLEClient/2.1/car    	   state: stopped
JEE5/EXAMPLEClientServer/2.1/car   state: running

You can run the Application Client with this command:

%GERONIMO_HOME%/bin/client JEE5/EXAMPLEClient/2.1/car

You should notice the application client message in the Geronimo console.

Powered by Atlassian Confluence (Version: 2.2.9 Build:#527 Sep 07, 2006) - Bug/feature request

Unsubscribe or edit your notifications preferences