Testing Java EE Application Clients

Java™ EE application clients are similar to regular Java applications. Both contain a main() method that runs and continues running until the client virtual machine stops. Both can run as typical "fat client" applications in order to display a GUI that connects to a set of EJB beans for persistence and business logic, or as server applications that provide services over the network. However, a Java EE application client has several advantages over regular Java applications because it runs within a lightweight server container. This container can provide the application client with services that were previously available only to other Java EE components.

Before you begin

  • Create an EAR that contains a complete application client project.

About this task

Using Java EE application clients instead of regular Java applications has the following advantages:

  • Ability to run inside a server container, providing richer APIs.
  • Use of Java EE security, including authentication and server-specific functions that might include features such as single-sign-on.
  • Guaranteed Java Platform, Enterprise Edition platform APIs available, and container extensions.
  • Simple JNDI lookup: initial context properties are picked up from the container.
  • Packaged like other Java EE components, providing portability, easy deployment, and clean packaging. A deployer can modify the deployment information in order to move to a different server without changing code.
  • Use of the java:comp namespace to indirectly reference EJB beans.

To build a full command line to start an application client, complete the following steps:

Procedure

  1. Switch to the Debug perspective (Window > Open Perspective > Other > Debug).
  2. In the main toolbar, expand the Run icon Image of the run icon. and select Run Configurations, alternatively expand the Debug icon Image of the debug icon. and select Debug Configurations.
  3. Select WebSphere Application Server vx.x Application Client, where x.x is the version level of the WebSphere® Application Server and click New launch configuration.
  4. In the Name field, enter the name of your configuration.
  5. In the Application tab, select your enterprise application from the Enterprise Application list.
  6. In the Arguments tab, you can add Program arguments, VM arguments and specify your working directory. All WebSphere Application Server client launcher arguments begin with -CC. The default Program argument is -CCverbose=true, which provides useful debugging information and at run time. Any arguments that do not start with -cc pass to your application at run time. For details on the various Program arguments and VM arguments, see the launchClient tool topic available in the Information Center for WebSphere Application Server.
  7. Package everything that is required by your application into your EAR file. However, if you want to reference classes that are not in the EAR file, use the -CCclasspath parameter. For details on the -CCclasspath parameter, see the Java EE client application class loading topic available in the Information Center for WebSphere Application Server.
    Tip: The Classpath tab available in the launch configuration has lead to common usage errors, such as ClassNotFoundException. This Classpath tab is reserved for adding references for the launch configuration. Do not use the Classpath tab for referencing classes particular to running your application. Instead, specify your application references with the -CCclasspath parameter in the Arguments tab.
  8. After configuring your launch configurations, click Apply to set your configuration, then click Run to start the application client.
Icon that indicates the type of topic Task topic
Timestamp icon Last updated: July 17, 2017 21:58

File name: tappct.html