Modernizing Java EE Applications With WebSphere Liberty
Time to bring older apps up to snuff.
Join the DZone community and get the full member experience.Join For Free
Application modernization is a journey. There is no magic. Modernizing applications in several little steps is the approach that I recommend. In this article, I describe how to modernize WebSphere Traditional applications with modern WebSphere Liberty runtimes.
This article is part of a series of articles that documents how to modernize a sample Java EE application from 2010 with modern technologies.
The sample application is a simple e-commerce application. The original application and the source code of all subsequent modernization steps are available as open source on GitHub.
The first part of this series explained how to run WebSphere Traditional applications in containers. This part continues the journey and documents how to use a modern WebSphere Liberty runtime optimized for containers.
WebSphere Liberty is a comprehensive, flexible and secure Java EE and MicroProfile application server for modernizing and building the next era of applications and cloud-native services.
IBM WebSphere Liberty is a Java EE application server with a low-overhead Java runtime environment designed for cloud-native applications and microservices. WebSphere Liberty was created to be highly composable, start fast, use less memory and scale easily.
The WebSphere Liberty architecture shares the same code base as the open-sourced IBM Open Liberty (link resides outside IBM) server runtime. This provides additional benefits such as low-cost experimentation, customization and seamless migration from open source to production.
WebSphere Liberty Images
The first thing that needs to be done is to define the runtime of the application. There are a number of different WebSphere Liberty images available with different pros and cons. They differentiate in several ways: JVMs, JDK versions, Java versions, UBI images, etc. Check out the tags of these images on DockerHub:
Here is the Dockerfile I've used:
Note that the last line 'RUN configure.sh' can be ignored for development environments. I've been told that this is 'only' useful for production environments. Not executing this script will save you a lot of time during development.
WebSphere Liberty Configuration
In the next step, you need to define the pom.xml file or actually in this case the different pom.xml files. Old Java projects often used various sub-projects generating the different artefacts: ears, wars, and jars. I'll write more about this in one of the next blogs.
In the pom.xml you should declare the dependency to Java EE or now Jakarta EE. In many cases, this covers most of the necessary dependencies.
Next, the Liberty server configuration needs to be defined that describes which features to use, how to access databases, the HTTP endpoints, etc.
Here is what I've used:
Code Changes - WebSphere Application Server Migration Toolkit
The most challenging part is to do the necessary code changes. The WebSphere Application Server Migration Toolkit is a great help!
You can install the toolkit in Eclipse and create a 'Software Analyzer Configuration'.
Choose the option 'WebSphere Application Server Version Migration'.
Choose the source and the target.
In this example three code changes need to be done. The results can be found in the 'Software Analyzer Configuration' view, especially under the Java Code Review tab.
The first necessary change is to replace the usages of 'org.codehaus.jackson'. The Eclipse 'Help' view describes easily what needs to be changed.
The next required change is to replace 'com.ibm.json' with an open source package in Java EE.
The third change is the EJB lookups (which might not be necessary anymore with the latest Liberty versions).
In addition to the Eclipse Migration Toolkit Transformation Advisor also displays some of these results. Check out my previous article how to run this tool.
Here are the results of Transformation Advisor:
The reason why not all three necessary code changes are displayed is because Transformation Advisor tries to make modernizations as easy as possible. So rather than showing the results to upgrade to WebSphere Liberty with Java EE 8, the tool recommends upgrading to Open Liberty with Java EE 7 since fewer changes are required.
In the next article I'll describe how to split the frontend from the business logic.
All articles of this series can be found in the repo.
Published at DZone with permission of Niklas Heidloff, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.