Create a Liberty application client manually
We can create a Liberty application client from the command line.
We enable the Java EE Application Client 7.0 or Java EE Application Client 8.0 feature in the client.xml file only. We create a Liberty application client manually using the javaeeClient-7.0 feature. These directions also apply to configurations that use the javaeeClient-8.0 feature.
- cd LIBERTY_HOME/wlp/bin
- Create a client.
-
C:\wlp\bin> client create client_name
If we do not specify a client name, defaultClient is used.
Example: mo@machine01:~> client create client_name
- client create client_name
If the client is created successfully, we receive the following message:
- Client client_name created.
We 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.
- 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
- Place the EAR file under the wlp/usr/clients/client_name/apps directory.
- Update the client.xml file to configure the 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 we 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
We can enable security (SSL, CSIv2, JAAS) for the 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.