Using EJB Access Beans with Java application clients

With WebSphere, Java application clients consist of the following models:

  • Java EE application client, which supplies a container that provides access to system services for the application client code.
  • Java thin application client, a lightweight, downloadable Java application runtime that is capable of interacting with enterprise beans.

For more information about these client modules, refer to the WebSphere Knowledge Center documentation.

The following sections assume that you have chosen to use a Java EE application client. If you are using a Java thin application client, consult the WebSphere Knowledge Center for the instructions that are appropriate for your WebSphere release.

Complete the following steps to use EJB Access Beans with a Java application client:

  1. Start with a HATS EJB project that contains one or more macros, Integration Objects, and other resources, and a HATS project to which you have exported EJB Access Beans from the HATS EJB project.
  2. Create a Java EE application client as documented in the Knowledge Center for your version and edition of WebSphere Application Server. To follow these instructions, choose to generate a Main class, and a deployment descriptor. Put this new project into the same enterprise archive (EAR file) as the HATS EJB project. Add these jar files as dependent jars:
    • The EJB .jar file of the HATS EJB project
    • hatscommon.jar
  3. Move your EJB Access Beans to the application client project. Copy the IntegrationObject folder that holds the EJB Access Beans from the HATS project to the appClientModule directory of the application client project.
  4. Build your test client in the Main class that was generated in your application client by implementing the code to instantiate your EJB Access bean and run it.
  5. If you are using the Java EE application client, add the EJB reference and environment variables to the client deployment descriptor:
    1. Open META-INF\application-client.xml.
    2. On the Design tab of the Application Client Descriptor Editor, do the following:
      1. Click Add and choose to add an environment variable:
        • Name: Copy the value of the last part of the HPUBEJB2_REFERENCE string in the EJB Access Bean into this field. For example, it might say
          HPUBEJB2_REFERENCE1318657356
        • Type: java.lang.String
        • Value: ejb/ejb_project_name, where ejb_project_name is the name of your HATS EJB project.
      2. Click Add and choose to add an EJB reference:
        • EJB Reference name: ejb ejb_project_name, where ejb_project_name is the name of your HATS EJB project.
        • EJB Reference type: Session
        • Home: com.ibm.HostPublisher.EJB.HPubEJB2Home
        • Remote: com.ibm.HostPublisher.EJB.HPubEJB2
        • EJB link: ejb/ejb_project_name, where ejb_project_name is the name of your HATS EJB project.
  6. Publish the EAR file to your test server.
  7. Test the application client:
    1. Open the Debug perspective.
    2. Start the application server.
    3. Click the Debug drop-down list , and select Debug to define and start the test environment for the Java EE application client that you created:
      1. Click WebSphere Application client.
      2. Click New.
      3. Click the Application tab and complete the fields:
        • In the Name field, type a name for your test configuration that is unique to your application client.
        • Select the WebSphere server type.
        • Select the EAR that your application client resides in.
        • Select your application client module.
        • Enable the application client to connect to a server and choose either a specific server or a provider URL.
        • Click Apply.
        • Click Debug to start the test environment. You will see the output of your test client in the console.
  8. Export the application client. From the Navigator view, right click the name of the application client project and select Export. Export it as an EAR file.