Introduction
EJB (Enterprise java bean) is server-side software that helps to summarize the business logic of a particular application. With EJB, we can develop secured, robust, and scalable distributed applications.
A ZIETrans EJB project provides access to the host interactions that are encapsulated in Integration Objects. It contains one or more Integration Objects. These Integration Objects provide host data to an EJB client, i.e., another ZIETrans application, a user-written Java program, a Web application, or another EJB. A ZIETrans EJB project enables you to separate the collection of the host data from its presentation.
In this blog, we will understand how to use ZIETrans EJB Beans in an application client project.
Using ZIETrans EJB Access Beans with Java application clients
Follow the below steps to use EJB Access Beans with a Java application client:
- Create a ZIETrans EJB project that contains one or more macros, Integration Objects, and other resources, and a ZIETrans project. Right-click on the Integration object and export the EJB Access bean to the ZIETrans project as shown below:
Figure 1: Export EJB Access bean to ZIETrans Project
2. Create a new Application client project, choose to generate a Main class and a deployment descriptor. Put this new project into the same enterprise archive (EAR file) as the ZIETrans EJB project.
3. Add these jar files as dependent jars in manifest files:
-
- The EJB .jar file of the ZIETrans EJB project
- hatscommon.jar
4. Move your EJB Access Beans to the application client project.Copy the Integration Object folder that holds the EJB Access Beans from the ZIETrans project to the appClientModule directory of the application client project.
Refer to below screenshot for adding the jars and copying Integration objects.
Figure 2: Adding the dependency jars and copying the Integration objects from ZIETrans Project
5. Build your test client in the Main class generated in your application client by implementing the code to instantiate your EJB Access bean and run it.
Refer to below screenshot.
Figure 3: Instantiate EJB access bean in the Main class
6. Add the EJB reference and environment variables to the client deployment descriptor:
- Open META-INF\application-client.xml.
- On the Design tab of the Application Client Descriptor Editor, do the following:
- 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 ZIETrans EJB project.
- 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 ZIETrans EJB project.
- EJB Reference type: Session
- Home: com.ibm.HostPublisher.EJB.HPubEJB2Home
- Remote: com.ibm.HostPublisher.EJB.HPubEJB2
- EJB link: ejb_project_name, where ejb_project_name is the name of your ZIETrans EJB project.
- Click Add and choose to add an environment variable:
Refer to the below screens for more information:
Figure 4: Adding EJB Reference name
Figure 5: Adding Environment variable
7. Save the workspace and clean the projects.
Running your application Client on WebSphere Server
- Export the Application client project. Right-click the name of the application client project and select Export. Export it as an EAR file.
- Copy your EAR file into the bin directory of the WebSphere. In the below location:
C:\Program Files\ibm\WebSphere\AppServer\bin
3. Install this EAR on the WebSphere server. Open admin console of WAS, and select
Application Types > WebSphere enterprise application > Install. Select next and add both the projects as below:
Figure 6: Installing EJB project in WAS
4. Provide the JNDI name as below:
com/ibm/HostPublisher/EJB/EJBProj_name
Figure 7: Providing JNDI name
Click next and install on WAS.
5. Open the command prompt and change the directory to bin folder wherever ear has been copied. Run the below command.
launchClient EAR_name -CCBootstrapPort=bootstrap_address_of_ server
Example: launchClient ZIETran_EAR.ear -CCBootstrapPort=2812
Note: The bootstrap address of server can be found at below location.
WebSphere application server > Server > communications > ports.
To understand more about ZIETrans EJB and to create EJB projects, refer to below ZIETrans link:
https://zietrans.hcldoc.com/help/index.jsp
Here is the attached code of application client for reference:
Start a Conversation with Us
We’re here to help you find the right solutions and support you in achieving your business goals.