Upgrading Service Builder

Upgrading Frameworks and Features

Step 3 of 4

Liferay DXP 7.2 continues to use Service Builder, so you can focus on your application’s business logic instead of its persistence details. It still generates model classes, local and remote services, and persistence.

Upgrading most Service Builder portlets involves these steps:

  1. Adapt the code to Liferay DXP 7.2’s API
  2. Resolve dependencies
  3. Build the services

Start by adapting the code.

Step 1: Adapt the Code to Liferay DXP 7.2’s API

Adapt the portlet to Liferay DXP 7.2’s API using the Upgrade Planner. When running the planner’s Fix Upgrade Problems step, many of the existing issues are autocorrected. For remaining issues, the planner identifies code affected by the new API and ways to adapt it.

For example, consider an example portlet with the following compilation error:

/html/guestbook/view.jsp(58,1) PWC6131: Attribute total invalid for tag search-container-results according to TLD

The view.jsp file specifies a tag library attribute total that doesn’t exist in Liferay DXP 7.2’s liferay-ui tag library. Notice the second attribute total.

                    guestbookId, searchContainer.getStart(),
                    guestbookId)%>" />

Remove the total attribute assignment to make the tag like this:

                    guestbookId, searchContainer.getStart(),
                    searchContainer.getEnd())%>" />

Resolve these error types and others until your code is adapted to the new API.

Step 2: Resolve Dependencies

To adapt your app’s dependencies, refer to the Resolving a Project’s Dependencies tutorial. Once your dependencies are upgraded, rebuild your services!

Step 3: Build the Services

An example change where upgrading legacy Service Builder code can produce differing results is explained below.

A Liferay Portal 6.2 portlet’s service.xml file specifies exception class names in exception elements like this:

<service-builder package-path="com.liferay.docs.guestbook">

In Liferay Portal 6.2, Service Builder generates exception classes to the path attribute package-path specifies. In Liferay DXP 7.2, Service Builder generates them to [package-path]/exception.

Old path:


New path:


For example, the example portlet’s package path is com.liferay.docs.guestbook. Its exception class for exception element GuestbookName is generated to docroot/WEB-INF/service/com/liferay/docs/guestbook/exception. Classes that use the exception must import com.liferay.docs.guestbook.exception.GuestbookNameException. If this upgrade is required in your Service Builder project, you must update the references to your portlet’s exception classes.

Once your Service Builder portlet is upgraded, deploy it.

The portlet is now available on Liferay DXP. Congratulations on upgrading a portlet that uses Service Builder!

« Upgrading Service Builder Service InvocationMigrating Off of Velocity Templates »
¿Fue útil este artículo?
Usuarios a los que les pareció útil: 0 de 0