This tutorial shows you how to upgrade servlet-based portlets. It refers to
code from before and after upgrading a sample servlet-based portlet called
Sample JSON (project
sample-json-portlet). The portlet shows a Click me
link. When users click the link, the Liferay logo appears.
To get the most from this tutorial, download and refer to the original sample portlet source code and the upgraded source code.
Here are the sample portlet’s characteristics:
- Processes requests using a servlet that extends
- View layer implemented by JSPs
- Processes data using JSON objects
- Relies on manual dependency management
- Depends on third-party libraries that Liferay Portal 6.2 provides
- Embeds additional dependencies in its
- Developed in a Liferay Plugins SDK 6.2
To upgrade a servlet-base Portlet, adapt your code to Liferay DXP 7.1’s API using the Liferay Upgrade Planner. When you ran the planner’s Fix Upgrade Problems step, many of the existing issues were autocorrected or flagged. For any remaining errors, consult the Resolving a Plugin’s Dependencies article.
Liferay’s Upgrade Planner identifies code affected by the new API, explains the API changes and how to adapt to them, and in many cases, provides options for adapting the code automatically.
The sample portlet relied on Liferay Portal to provide several dependency JAR
files. Here’s the
portal-dependency-jars property from the portlet’s
portal-dependency-jars=\ dom4j.jar,\ jabsorb.jar,\ json-java.jar
Instructions for using packages that Liferay DXP exports are found here. Liferay DXP 7.1’s core system exports the package this portlet needs from each of the above dependency JARs.
The upgraded sample portlet continues to specify these JARs in the
portal-dependency-jars property. They’re made available to the portlet at
compile time. But to keep compile time packages from conflicting with the core
system’s exported packages, the Liferay Plugins SDK 7.0 excludes the JARs from
the plugin WAR.
Next, deploy your portlet as you always have.
The server prints messages that indicate the following portlet status:
- WAR processing
- WAB startup
- Availability to users
The portlet is installed to Liferay’s OSGi runtime and is available to users.
Congratulations! You’ve upgraded and deployed your servlet-based portlet to Liferay DXP 7.1.
Migrating Plugins SDK Projects to Workspace and Gradle
Using Dependency Management Tools