Digital Developer Conference: Cloud Security 2021 – Build the skills to secure your cloud and data Register free

Archived | Java EE application modernization with OpenShift

Archived content

Archive date: 2021-02-25

This content is no longer being updated or maintained. The content is provided “as is.” Given the rapid evolution of technology, some content, steps, or illustrations may have changed.


This code pattern shows how to modernize a Java EE application running on Open Liberty by transforming it into Kubernetes-based microservices. It demonstrates steps to create a container image of a RESTful application for a conceptual health records system connected to a MySQL database and deployed in an enterprise Kubernetes environment.

This sample code is part of a series of code patterns that focuses on a fictional health care company and demonstrates app modernization using the enterprise Kubernetes environment of Red Hat OpenShift on IBM Cloud™. You learn how to populate and access large amounts of data on a MySQL database using REST APIs from a Java EE application. In addition, you use OpenShift’s Source-to-Image toolkit by deploying both Node.js and PHP web applications that make RESTful calls to the APIs from the Java EE application and display the data from the MySQL database. To learn more about Source to Image, you can watch this video.


“Example Health” is a conceptual healthcare or health insurance company. It has been around a long time and has hundreds of thousands of patient records. The company’s health records look very similar to the health records of most insurance companies.

Originally, Example Health used a monolithic application structure for the health records application. The application structure was a full stack Java application running on WebSphere Application Server, connected to a DB2 database on System z.

Recently, Example Health decided to modernize the health records application and break it up into microservices. The development team decided to move to a SQL database connected to a Java EE application (as shown in this code pattern) running on Open Liberty for the business logic and a Node.js application for the patient application user interface. In addition, Example Health decided to deploy these applications on Red Hat OpenShift on IBM Cloud.

Since moving to OpenShift, Example Health has expanded to include new microservices that include a PHP application](/patterns/app-modernization-php-s2i-openshift/) for health records administrators and a Node.js analytics application.

When you use this code pattern, you understand how to transform a traditional Java application into microservices on the cloud.


Java EE app modernization with OpenShift architecture flow diagram

  1. The user makes a call to one of the APIs for the Java EE application, which is behind the OpenShift application load balancer.
  2. The load balancer routes the call to the Open Liberty container running in a Kubernetes pod.
  3. The Java EE application queries the MySQL database running in the cloud to get the desired data.
  4. The MySQL database sends back the data to the Java EE application, where it is handled accordingly.
  5. The data is converted into JavaScript Object Notation (JSON) format, which is returned to the API and the user.


Ready to give it a try? Find detailed technical steps for this code pattern in the file in the GitHub repository.

  1. Create a Red Hat OpenShift on IBM Cloud cluster.
  2. Provision a Compose for MySQL database.
  3. Create a Docker container image of a Java EE application.
  4. Push the container image to a Docker Hub repository.
  5. Change the image key in the kubernetes-openshift.yaml file.
  6. Edit the secret values for your MySQL cloud deployment.
  7. Set database access parameters for an Open Liberty server.
  8. Deploy the application to the Red Hat OpenShift on IBM Cloud cluster.
  9. Expose the application to the internet.
  10. Populate the MySQL database with synthetic patient health records.