Modernizing Java applications
watsonx Code Assistant Standard plan
You can modernize your WebSphere Application Server traditional application to Liberty. To modernize your application, you first upload a migration bundle or build and analyze your application, and then fix your application issues.
Before you begin, set up your enterprise Java environment.
Eclipse IDE only: For best results with a multimodule Java application, ensure that you import the aggregator module and each submodule as separate projects within the Eclipse workspace. Watsonx Code Assistant is unlikely to successfully introspect your project if you import the top-level directory as a single project.
Complete either the steps to upload your application migration bundle or the steps to analyze your application. After you complete one set of steps, you can then fix issues with the migration. The steps to fix the issues are the same for both the migration bundle steps and application analysis. After you fix the issues, you have a modernized application.
Time required to analyze your code
The amount of time to analyze your application varies. The following times are typical.
Time | Application details |
---|---|
Seconds to a few minutes | Fewer than 100 classes |
2 to 10 minutes | 20,000 to 50,000 lines of code |
10 or more minutes | 300,000 lines of code |
When watsonx Code Assistant analyzes your application, it excludes some third-party packages from code analysis by default. For more information, see Third-party packages that are excluded from application analysis.
Using a migration bundle to modernize your application
The following steps assume that you are using IBM Cloud® Transformation Advisor version 3.10 or later to generate a migration bundle. The migration bundle contains a list of modernization issues that need to be addressed. It also contains automatically generated configuration information to enable the application to function properly in Liberty.
If you already uploaded and analyzed a migration bundle for your project, uploading a new migration bundle overwrites the existing analysis.
Before you modernize your application, do a full build of your application to ensure that you are starting from a known good application build. This build also ensures that class files are up to date with the latest source code, which is a requirement before you run automations that add changes for Java version upgrades.
If you revert the changes to your code, you must click Return to upload / analyze and do a full analysis if you want to modernize your application again.
-
In your IDE, right-click on any item in the hierarchy in the directory of the application that you want to modernize, click watsonx Code Assistant, then click Modernize to Liberty.
-
On the Modernize <your application name> page, upload the migration bundle.
The IDE analyzes your project folder, gathers information about your application, and then uploads the migration bundle that Transformation Advisor generates.
-
Click Upload migration bundle.
-
Select the application bundle
.zip
file from the list and click Open.When the the process to upload the migration bundle completes, the Modernize <your application name> page displays the following configuration files that are in the bundle:
server.xml
is the configuration file for Liberty and is required to start your application.Containerfile
is required only to build a container image for your Liberty application.
-
Select the files to add to your project and then click
Proceed
.- (Required) Select the
server.xml
file. - (Optional) Select the
Containerfile
file only if you are building a container image for your Liberty application.
- (Required) Select the
When the upload of the migration bundle completes, the issues to fix or review are displayed.
-
-
Fix issues with the application.
Depending on the issues to fix, the ability to fix them can be automated, assisted, or self-directed. The issues on the Additional information tab don't require a code change, but you might need to verify or test them and make a code change if you want.
Analyzing your application to modernize it
The following steps assume that you are analyzing your application instead of a using a Transformation Advisor migration bundle to modernize your application. The analysis provides you with a list of issues to address and a limited server configuration
in the server.xml
file. The server.xml
file contains a list of features that your application uses, but it doesn't include other configuration information such as database connections or JMS configurations.
If you revert the changes to your code, you must click Return to upload / analyze and do a full analysis if you want to modernize your application again.
-
In your IDE, right-click in the directory that you want to modernize, click watsonx Code Assistant, then click Modernize to Liberty.
-
On your Modernize <your application name> page, expand Analyze application, and click Start analysis.
-
Select the analysis parameters, which define the rules that the application server is analyzed against.
-
Select the application server source and the application server target.
-
Optionally change the Java SE source, which is displayed automatically with a recommended value.
The recommended value is based on the Java SE version that watsonx Code Assistant recommends for the application server source. Your application server might be using a different Java SE version than what is recommended. If it is, then change the Java SE source to the version that your application server uses.
For example, watsonx Code Assistant recommends Java SE 8 for WebSphere Application Server V8.5.5 even though your application server might be using an earlier version of Java SE.
The minimum-supported Java version is Java 5.
-
Select the Java SE target.
-
Click either Analyze or Build and analyze.
Application analysis is done on the application binary. The application must be built before analysis begins. You can either automatically or manually build the application.
- To automatically build and analyze the application, click Build and analyze.
- If you manually build the application, first build it and then click Analyze.
After your application is built and analyzed, the issues to fix or review are displayed.
When you click Build and analyze, the application is built at its current Java source version so it can be analyzed for Java upgrade issues. Make sure that the IDE has the Java developer kit of the Java source version that is configured so the IDE can successfully build the application.
-
-
Fix issues with the application.
Depending on the issues to fix, the ability to fix them can be automated, assisted, or self-directed. The issues on the Additional information tab don't require a code change, but you might need to verify or test them and make a code change if you want.
Fixing issues and reviewing additional information for your application
The Modernize <your application name> page lists the following information:
- The application server source and the application server target
- The Java SE version source and the Java SE version target
- Links to a technology report, an inventory report, and an analysis report
- Tabs for issues to fix, which can be automated, assisted, or self-directed fixes, and additional information.
The target Java developer kit is required when you run automated fixes and when you build the application after the Java version target changes are made. Make sure that the target Java developer kit is configured for your IDE.
- The Eclipse IDE extension automatically tries to find the correct Java developer kit that matches the Java version target from the set of all configured Java developer kits in the IDE.
- In the Visual Studio Code IDE, you must manually change the Java developer kit configuration.
Completing automated fixes
If you have an Automated fixes tab with one or more fixes, select the tab.
Because watsonx Code Assistant completes the fixes for you, you do not need to make any code changes. The large language model (LLM) is not used for automated fixes.
- Expand the Instructions and read them.
- Optionally open the issue to review the description of the issue.
- Click Run automated fixes.
- The Automated fixes are fixed.
- External issues remain in the list until you update the associated dependency.
- When Run automated fixes completes, click Rebuild and refresh to update the list of issues.
If the automated fixes fail to run and produce compilation errors in the console output, make sure to update the version of the maven-compiler
plug-in to 3.13.0 or newer.
Completing assisted fixes
If you have an Assisted fixes tab with one or more fixes, select the tab.
Although you fix your code, watsonx Code Assistant assists you by providing suggestions in the chat on how to change your code.
The level of assistance available for the issues varies with the issue. The assisted fixes help you to fix the issue, and sometimes a code suggestion gets you all the way or most of the way. Other times, the code suggestion might be as simple as removing an old API to prevent a compilation failure, and no further action is required from you. It is important to follow steps for each assisted fix to understand the value and limitations of each assisted fix. In cases where a complete code suggestion is not provided, you can think of the assisted fix as a conversation starter in the chat. Continue to engage with the chat to build your understanding of the issue and its resolution.
For a list of issues associated with assisted fixes, see the Assisted fixes reference.
To use assisted fixes:
-
Expand the Instructions and follow the instructions.
-
For each issue, expand it.
-
Click Read more to expand the issue.
-
Click the file that is listed in the issue.
The file opens in the editor.
-
Expand the issue to view the issue details.
-
If in the details you are directed to select a code snippet, select it.
-
Click Help me for assistance in fixing the issue.
If you are using Visual Studio Code, the following restrictions apply:
- Make sure that you select Java code in only one active editor.
- Make sure that the active editor in which you selected Java code is in a different editor group than the Modernize to Liberty or Java Upgrade view.
-
Follow the code suggestions in the chat so you modify the code to fix the issues.
Sometimes, the chat provides an informational response instead of a code suggestion.
-
As you fix issues, click Rebuild and refresh until all assisted fixes are fixed.
Completing self-directed fixes
If you have a Self-directed fixes tab with one or more fixes, select the tab.
You change the code and determine how to fix the code, but you can get help from the chat.
-
Expand the Instructions and follow the instructions.
-
Expand each issue.
-
Click Read more to expand the issue.
-
Click the file that is listed in the issue.
The file opens in the editor.
-
Click Start chat, which is displayed for each occurrence of the issue.
The chat window opens so you can get help for the occurrence. For example, you can ask the code assistant what the current code does. Or, you can ask if an alternative implementation exists for the problematic code.
-
As you fix issues, click Rebuild and refresh until all self-directed fixes are fixed.
Addressing additional information
If you have an Additional information tab with a number of one or more on it, select the tab.
The issues listed on the tab are determined the same way that issues on other tabs are determined. Although the additional information issues do not require a change to your code, review the issues so you can ensure that your application is working when your code is migrated.
The additional information might indicate issues, such as minor behavioral changes in an API or connectivity concerns in databases or user registries, and what to do about them.
For example, you have a database that your application connects to. From reading the issue for this situation, you make sure that the host and port configured for the application are valid and accessible when the application is migrated.
-
Expand the instructions and follow them.
-
Click each issue.
- Click Read more to expand the issue.
- Click the link on the file that is listed in the issue to review the code.