In today's fast-paced business environment, organizations are constantly looking for ways to improve their agility and reduce costs. One way to achieve this is by modernizing and migrating applications from traditional IBM WebSphere Application Server (WAS) to a containerized IBM WebSphere Liberty.
The traditional IBM WebSphere Application Server is a monolithic architecture that requires a significant amount of resources and maintenance. In contrast, containerized IBM WebSphere Liberty is a lightweight, cloud-native architecture that allows for faster deployment, scaling, and management of applications.
Containerization of IBM WebSphere Liberty allows for better resource utilization and improved scalability. With a containerized architecture, applications can be deployed and scaled independently, allowing organizations to optimize resources and reduce costs. It allows for better isolation of applications, improving security and reducing the risk of conflicts.
Its containerization also allows for better integration with popular container orchestration platforms such as Kubernetes, which makes it easy to manage and scale large numbers of containers.
Furthermore, IBM WebSphere Liberty architecture is designed for cloud-native and microservices-based applications, it's based on OSGi technology and provides a small footprint and a dynamic class loading, this characteristics enable the liberty server to start and stop features on demand, reducing the memory and CPU consumption.
In this article, we will explore the process of containerizing the application, deploying it on IBM WebSphere Liberty and migrating it, using a step-by-step guide and code snippets to illustrate each step.
1. Install Docker on the second Linux server
Install the required packages for Docker by running the following command:
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
Add the Docker repository by running the following command:
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Install Docker CE by running the following command:
sudo yum install docker-ce
Start the Docker service and enable it to start automatically on boot by running the following commands:
sudo systemctl start docker
sudo systemctl enable docker
2. Install IBM WebSphere Liberty
Download the IBM WebSphere Liberty image from the official website and save it on the second Linux serverLoad the image into Docker by running the following command:
docker load -i /path/to/wlp-webProfile8.tar.gz
Start a container running the IBM WebSphere Liberty image by running the following command:
docker run -it -p 9080:9080 -p 9443:9443 websphere-liberty:webProfile8
This command will start a container running the IBM WebSphere Liberty image and will map port 9080 and 9443 in the container to port 9080 and 9443 on the host machine, respectively.
3. Backup and prepare the application
Create a backup of the application files and configuration files, such as server.xml and web.xml, on the first Linux server by running the following command:
tar -cvzf myapp_backup.tar.gz /path/to/myapp
Copy the backup of the application files and configuration files to the second Linux serverReview the application's configuration files and update them to match the new environment. This may include updating the JNDI names, data sources, and other settings that are specific to the IBM WebSphere Application Server Traditional environment.
4. Containerize the application
Create a Dockerfile for the application by creating a new file called Dockerfile in the directory where the application files are located.
Add instructions to the Dockerfile for copying the application files, setting environment variables, and configuring the application.Here's an example of a basic Dockerfile that copies the application files, sets the JAVA_HOME environment variable, and configures the application to run on port 9080:
FROM websphere-liberty:20.0.0.6-full-java8
COPY myapp.war /config/dropins/
ENV JAVA_HOME /opt/ibm/java/jre
EXPOSE 9080
5. Deploy the containerized application on IBM WebSphere Liberty
Build the Docker image by running the following command:
docker build -t myapp:latest .
This command will create an image with the tag "myapp:latest"Start a container running the myapp image by running the following command:
docker run -it -p 9080:9080 myapp:latest
6. Test the application
Test the application to ensure that it is running correctly on IBM WebSphere Liberty by accessing the application through its endpoint and checking for any errors or issues.
You can check the configuration to make sure everything is running as expected:
The Liberty server configuration is stored in the server.xml file, which is located in the /config directory of the container. You can access this file by running the following command:
docker exec -it <container_name> /bin/bash
This command will open a shell inside the container, then you can navigate to the /config directory and edit the server.xml file using a text editor such as vi or nano.
You can also use the Liberty command line interface (wsl) to access and configure the server by running the following command:
docker exec -it <container_name> wsl <command>
Where <container_name>
is the name of the container running your application, and <command>
is the command you want to run.
Another way is to use the Liberty WebSphere administration console by accessing it through the browser using the following URL:
http://<hostname>:<http_admin_port>/ibm/console
Where hostname
is the hostname or IP address of the server running the container and http_admin_port
is the port that you exposed when you run the container (default is 9080)
You can also use the IBM WebSphere Liberty Configuration Editor, which is a web-based tool that allows you
allows you to configure the Liberty server and your applications in a graphical user interface. The Configuration Editor is included with the Liberty runtime and can be accessed by opening a browser and navigating to the following URL:
http://<hostname>:<http_admin_port>/ibm/console/config
Finally, you can also use the Liberty REST API to access and configure the server and your applications. With the REST API, you can perform configuration tasks, such as modifying server settings, creating or modifying applications, and starting or stopping servers or applications. You can find the Liberty REST API documentation on the IBM website.
It's important to note that the configuration of your application running on IBM WebSphere Liberty in a containerized environment may differ from the configuration of the same application running on IBM WebSphere Application Server Traditional, so you should carefully review the application's configuration files and make any necessary adjustments.
I have to mention that migrating application from one environment to another can be tricky and requires testing and validating the application in the new environment before going live. Also, it's recommended to have a plan for rollback in case of any issues.
In the next time we discuss about modernizing an application, we will delve deeper into the topic of modernizing a monolithic application to a microservices-based architecture, running on a containerized solution. We will see how to decompose a monolithic application into smaller, more manageable microservices, and how to deploy and manage these microservices using popular container orchestration platforms.
Here are some references you can use to learn more about modernizing and migrating applications from IBM WebSphere Application Server to IBM WebSphere Liberty on Docker:
These resources will provide you with detailed information and guidance on how to install, configure, and deploy IBM WebSphere Liberty on Docker, as well as best practices for migrating applications from IBM WebSphere Application Server to IBM WebSphere Liberty.
Youssef Sbai Idrissi, 2023.Follow me on LinkedIn for more tips.