DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • Managed Scheduled Executor Service vs EJB Timer
  • Getting Started With Jakarta EE and Eclipse MicroProfile
  • A Systematic Approach for Java Software Upgrades
  • Dust Actors and Large Language Models: An Application

Trending

  • AI-Driven Test Automation Techniques for Multimodal Systems
  • Monolith: The Good, The Bad and The Ugly
  • The Role of AI in Identity and Access Management for Organizations
  • Agentic AI for Automated Application Security and Vulnerability Management
  1. DZone
  2. Coding
  3. Java
  4. Modernizing Java EE Applications With WebSphere Liberty

Modernizing Java EE Applications With WebSphere Liberty

Time to bring older apps up to snuff.

By 
Niklas Heidloff user avatar
Niklas Heidloff
DZone Core CORE ·
Jan. 31, 21 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
5.1K Views

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:

Dockerfile
 




x
16


 
1
FROM ibmcom/websphere-liberty:20.0.0.12-kernel-java8-openj9-ubi
2
USER root
3
COPY ./liberty/server.xml /config
4
COPY ./liberty/server.env /config
5
COPY ./liberty/jvm.options /config
6
 
           
7
ARG SSL=false
8
ARG MP_MONITORING=false
9
ARG HTTP_ENDPOINT=false
10
 
           
11
COPY ./CustomerOrderServicesApp/target/CustomerOrderServicesApp-0.1.0-SNAPSHOT.ear /config/apps/CustomerOrderServicesApp-0.1.0-SNAPSHOT.ear
12
COPY ./resources/ /opt/ibm/wlp/usr/shared/resources/
13
RUN chown -R 1001.0 /config /opt/ibm/wlp/usr/servers/defaultServer /opt/ibm/wlp/usr/shared/resources && chmod -R g+rw /config /opt/ibm/wlp/usr/servers/defaultServer  /opt/ibm/wlp/usr/shared/resources
14
 
           
15
USER 1001
16
RUN configure.sh



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.

XML
 




xxxxxxxxxx
1


 
1
<dependency>
2
   <groupId>javaee</groupId>
3
   <artifactId>javaee-api</artifactId>
4
   <version>8</version>
5
   <scope>provided</scope>
6
</dependency>



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:

XML
 




xxxxxxxxxx
1
31


 
1
<server>
2
  <featureManager>
3
      <feature>appSecurity-2.0</feature>
4
      <feature>ldapRegistry-3.0</feature>
5
      <feature>localConnector-1.0</feature>
6
      <feature>ejbLite-3.1</feature>
7
      <feature>jaxrs-1.1</feature>
8
      <feature>jdbc-4.1</feature>
9
      <feature>jpa-2.0</feature>
10
      <feature>jsp-2.3</feature>
11
      <feature>servlet-3.1</feature>
12
  </featureManager>
13
 
           
14
  <library id="DB2Lib">
15
    <fileset dir="/opt/ibm/wlp/usr/shared/resources/db2" includes="db2jcc4.jar db2jcc_license_cu.jar"/>
16
  </library>
17
 
           
18
  <dataSource id="OrderDS" jndiName="jdbc/orderds" type="javax.sql.XADataSource">
19
    <jdbcDriver libraryRef="DB2Lib"/>
20
    <properties.db2.jcc databaseName="${env.DB2_DBNAME}" password="${env.DB2_PASSWORD}" portNumber="${env.DB2_PORT}" serverName="${env.DB2_HOST}" user="${env.DB2_USER}"/>
21
    <connectionManager agedTimeout="0" connectionTimeout="180" maxIdleTime="1800" maxPoolSize="10" minPoolSize="1" reapTime="180"/>
22
  </dataSource>
23
 
           
24
  <httpEndpoint host="*" httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint">
25
    <tcpOptions soReuseAddr="true"/>
26
  </httpEndpoint>
27
 
           
28
  <application id="customerOrderServicesApp" name="CustomerOrderServicesApp-0.1.0-SNAPSHOT.ear" type="ear" location="CustomerOrderServicesApp-0.1.0-SNAPSHOT.ear">
29
    <classloader apiTypeVisibility="spec, ibm-api, third-party" />
30
  </application>
31
</server>



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).

Transformation Advisor

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.

What's Next?

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.

application Java EE Java (programming language) Application server Open source

Published at DZone with permission of Niklas Heidloff, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Managed Scheduled Executor Service vs EJB Timer
  • Getting Started With Jakarta EE and Eclipse MicroProfile
  • A Systematic Approach for Java Software Upgrades
  • Dust Actors and Large Language Models: An Application

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!