Automated Upgrades for your WebLogic 14.1.2 Applications

Oracle WebLogic Server customers tend to have a large number of applications running in production, and those applications tend to be critical to the customer’s business. When planning for an application upgrade, customers look to automate as much of the upgrade as possible to minimize the amount of time needed, to minimize human error, and to reduce costs of the upgrade. With the growth in complexity of distributed cloud deployments, and an increase in potential security vulnerabilities, upgrades are required more frequently. This combination of factors – large estate of applications, complex deployments, increased potential for security vulnerabilities, and the need for frequent updates – drives us to look for ways to alleviate the costs and risks of an application upgrade.

Luckily, application maintenance tools have evolved to meet application upgrade automation needs. One such automation tool is OpenRewrite. The WebLogic team is leveraging OpenRewrite and providing OpenRewrite recipes to automate your application upgrade process. Read on to learn more.

Background

OpenRewrite is a community-driven open-source project that enables developers to make intelligent updates to many applications in batches or concurrently. OpenRewrite provides an auto-refactoring engine that runs prepackaged, open-source refactoring recipes for common application migrations, security fixes, and stylistic consistency tasks. It is a great choice for the kinds of changes needed when upgrading to a new WebLogic Server version and the related JDK version.

Under the covers, the OpenRewrite refactoring engine is quite advanced. Before making any changes to your application code, OpenRewrite builds a Lossless Semantic Tree (LST) representation of the application. The LST represents all of the detailed aspects of the code, including a recursive structure of classes, methods, statements, invocations, variables, and so forth. It also preserves the formatting and whitespace in the code. LSTs are superior to Abstract Syntax Trees (ASTs) because they capture all of the detail needed to represent the application and to do accurate transformation. More info is available at Lossless Semantic Trees

OpenRewrite then makes transformations on the LST, rather than directly in the source code. The refactoring engine applies recipes to search for and modify structures in the LST. You can group recipes together into a stack. OpenRewrite applies each of these recipes in order, and can even run multiple passes of the recipes to modify the results of a later-run recipe.

After all of the transformations are complete, OpenRewrite then uses the LST back to regenerate the source code in the original source files, applying the transformations while preserving formatting. 

This level of intelligent automation enables the process to scale. You can run recipes against many repositories, with OpenRewrite providing consistently accurate transformations.

We’re not the only ones relying on OpenRewrite. Many other companies and projects are doing the same thing. Take a look at OpenRewrite’s Recipe Catalog.

rewrite-weblogic Recipes

With the release of WebLogic Server 14.1.2, the WebLogic team thought it would be helpful to provide OpenRewrite recipes to automate the application upgrade process. These recipes complement the automation tools that WebLogic provides for upgrading a WebLogic domain. 

As mentioned above, recipes can be grouped to achieve a specific outcome. In fact, the best practice is for a recipe to handle one particular type of change. This practice will enable you to have a library of recipes that you can flexibly combine to achieve your transformation objectives. We followed this best practice for the rewrite-weblogic recipes so that we could focus on the WebLogic-specific transformations, and we can rely on existing recipes from the OpenRewrite community for more general Java transformations.

Specifically, for WebLogic Server 14.1.2 application upgrades, we provided a composite recipe – a recipe that bundles multiple recipes into a single unit – UpgradeTo1412. This composite recipe includes these embedded recipes:

  • UpdateBuildToWebLogic1412
  • CheckAndCommentOutDeprecations1412
  • FacesMigrationToJakartaFaces2x
  • MigrateWebLogicSchemasTo1412
  • WebLogic1412JavaXmlBindMitigation

These recipes provide the changes needed for you to upgrade your application to WebLogic Server 14.1.2. These recipes DO NOT handle the required changes for the JDK. For those changes, we recommend using the Oracle-provided recipe mentioned above combined with a community-provided recipe that upgrades the application to run on JDK 17 or JDK 21: 

To run all of the recipes mentioned above, you can use Gradle or Maven to drive the process. For example, using Maven you can run the following command from the root folder of the project:

mvn -U org.openrewrite.maven:rewrite-maven-plugin:run \
  -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-migrate-java:RELEASE,com.oracle.weblogic.rewrite:rewrite-weblogic:LATEST \
  -Drewrite.activeRecipes=org.openrewrite.java.migrate.UpgradeToJava21,com.oracle.weblogic.rewrite.UpgradeTo1412

Before we move on, there are a couple of important things to point out:

  1. Upgrades for 3rd-party libraries require additional recipes. The recipes mentioned above address WebLogic and JDK upgrade needs, but they do not address other upgrades that your application may require.
  2. The WebLogic upgrade recipe must be run after the JDK recipe. The UpgradeTo1412 recipe does some cleanup work after the JDK upgrade recipe. If you run it before the JDK upgrade, that cleanup won’t happen.

WebLogic Cafe Tutorial

If you want to give the rewrite-weblogic recipes a quick spin, take a look the “Migrate WebLogic Cafe to WLS 14.1.2” tutorial on github. 

There is also a recording of the tutorial on the OracleWebLogic YouTube channel. 

Take-Aways and Next Steps

Upgrading your WebLogic applications just got a whole lot easier! With these new OpenRewrite recipes for Oracle WebLogic Server, you can automate the upgrade of your applications instead of manually looking for required updates, and then manually making the changes. 

Give it a try with your own applications! Read more at https://github.com/oracle/rewrite-recipes/tree/main/rewrite-weblogic. Any questions or issues, you can reach out to us on Slack: To join our channel, please visit this site to get an invitation. The invitation email will include details on how to access our Slack workspace. After you are logged in, please go to #wls-app-upgrade-openrewrite and say “Hello!”