Creating a Liberty application client manually

You can create a Liberty application client from the command line.

About this task

You enable the Java™ EE Application Client 7.0 or Java EE Application Client 8.0 feature in the client.xml file only.
Note: The following steps include directions for how to create a Liberty application client manually by using the javaeeClient-7.0 feature. These directions also apply to configurations that use the javaeeClient-8.0 feature.

Procedure

  1. Open a command line, then change directory to the wlp/bin directory.
    In the following examples, path_to_liberty specifies the location where you installed Liberty on your operating system.

    For Windows platformsExample on Windows systems: C:\Users\mo> cd path_to_liberty\wlp\bin

    For LINUX platformsExample on Linux®: mo@machine01:~> cd path_to_liberty/wlp/bin

  2. Run the following command to create a client, where client_name is the name that you want to give your client. If you do not specify a client name, defaultClient is used.

    For Windows platformsExample on Windows systems: C:\wlp\bin> client create client_name

    For LINUX platformsExample on Linux: mo@machine01:~> client create client_name

    client create client_name
    If the client is created successfully, you receive the following message:
    Client client_name created.

    You can find the client.xml file in the wlp/usr/clients/client_name directory. The file contains the javaeeClient-7.0 feature.

    Attention: If a default client exists, you get an error. If a default client does not exist, defaultClient is created.
  3. Run your client application by preparing an application (.ear) file with a client module (.jar) in it.
    Specify a main class in the MANIFEST.MF of the client module, for example:
    Manifest-Version: 1.0 
    Main-Class: com.ibm.ws.addressbook.ContactServiceClient_XMLInject 
  4. Place the EAR file under the wlp/usr/clients/client_name/apps directory.
  5. Update the client.xml file to configure your application, for example:
    <client>
    	<featureManager>
    		<feature>javaeeClient-7.0</feature>
    	<featureManager>
    	<application id="CLIENT_APP" name="CLIENT_APP" type="ear" location="clientApp.ear"/>
    </client>
    If the specified client already exists, no client is created and you receive an exception message:
    CWWKE0005E: The runtime environment could not be launched.
    CWWKE0904E: It was not possible to create the client called client_name because 
    the client directory C:\wlp\usr\clients\client_name already exists.

What to do next

You can enable security (SSL, CSIv2, JAAS) for your application client by adding the appSecurityClient-1.0 feature to your client.xml file:
<featureManager>
	<feature>javaeeClient-7.0</feature>
	<feature>appSecurityClient-1.0</feature>
</featureManager>

See information about configuring security on the application client.