The goal is to understand the modernization issues of the customers
application and learn how you can fix them by the code modification. The MTA report also provides the details in terms of the file name, path, and solution recommendations for each issue.
In this lab you will also analyze the customers application once again using MTA if the all issue are fixed.
According to the analysis report, the migration issues are related to external configurations with hard coded static IP addresses. Let’s dig into the issue on the code level.
Go to the web browser that opens the VS Code server. Explore the customers-tomcat-legacy
project to open PersistenceConfig.java
file in src/main/java/io/konveyor/demo/ordermanagement/config directory.
The dataSource() method creates an ApplicationConfiguration
instance to configure the JDBC variables such as driverClassName, url, user, and password. The ApplicationConfiguration ends up with referring to the hard coded IP address in persistence.properties
.
The customers-tomcat-ocp
project implements the Customers application with all the required changes and deploy the applications to OpenShift (Kubernetes). It also defines an OpenShift manifests file in the ocp
directory.
Let’s find out how to fix the above configuration issue. Move to customers-tomcat-ocp
project. Then, open PersistenceConfig.java
file in src/main/java/io/konveyor/demo/ordermanagement/config directory and pom.xml
file.
ApplicationConfiguration class isn’t required anymore to configure the JDBC variables but the datasource method still needs to use the environment instance. When you take a look at the pom.xml, the static properties file will be excluded when the application is building.
Using the kubernetes profile in the build is essential for the application to pick up the configuration file injected via a secret in the pod. That secret also has to be created manually which would normally be done by packaging with maven. To generate these Kubernetes resources, you usually run the following maven command with the Kubernetes profile.
Note
|
You don’t need to run the following maven command today since you already have the solution artifact ( |
mvn clean package -P kubernetes
Let’s go back to the MTA web console. Then, create a new project to analyze the solution artifact.
-
Project name:
New Customers Service
Select the customers-tomcat-solution.war
file from your local file system in the Add applications page.
Configure the project with the same settings and custom rules that we used for the Customers Service project. Once the report is finished, verify that it now reports 0
Story Points.
You have successfully migrated this app and now ready to deploy to OpenShift, congratulations!
➡️ 5. Rehost
⬅️ 3. Analyze