Testing J2EE Application Clients
J2EE application clients are like regular Java™ applications. They contain a main() method that is executed, and they continue executing until the client virtual machine terminates. They can be run as typical "fat client" applications, to display a GUI that connects to a set of EJBs for persistence and business logic, or as server applications that provide services over the network. However, a J2EE 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 used to be available only to other J2EE components.
Prerequisite: Create an EAR that contains a complete application client project.
Benefits of using J2EE application clients instead of regular Java applications include:
- Ability to run inside a server container, providing richer APIs.
- Use of J2EE security, including authentication and server-specific functions, that might include features such as single-sign-on.
- Guaranteed Java 2 platform APIs available, as well as container extensions.
- Simple JNDI lookup, because initial context properties are picked up from the container.
- Packaged like other J2EE components, providing portability, easy deployment, and clean packaging. This also supports the J2EE notion of a deployer being able to modify the deployment information in order to move to a different server without changing code.
- Use of the java:comp namespace to indirectly reference EJBs.
To build a full command line to launch an application client, do the following:
- Switch to the Debug perspective (
Window > Open Perspective > Other > Debug).
- In the main toolbar, expand the
Run icon and select
Open Run Dialog, alternatively expand the
Debug icon and select
Open Debug Dialog. An Application Client Launch Configurations dialog box opens.
- In the left pane of the Application Client Launch Configurations dialog box, select the type of configuration that you want to create, either WebSphere® v6.1, or v6.0 Application Client and click
New.
- In the
Name field, enter the name of your configuration.
- In the Application tab, select your enterprise application from the
Enterprise Application list. If you want to make changes to your code while you are debugging, select the
Enable hot method replace in debug mode check box.
- In the Arguments tab, you can add Program arguments and VM arguments as well as specifying your working directory. All WAS client launcher arguments begin with -CC. The default Program argument is -CCverbose=true, which will provide useful debugging information and at run-time. Any arguments that do not start with -cc will be passed to your application at run-time. For more information on the various Program arguments and VM arguments, refer to the WAS documentation for the Launch Client tool
- When you have completed configuring your launch configurations, click
Apply to set your configuration, then click
Run to launch the application client.
Related reference
Running multiple threaded WebSphere application clients