Legacy Knowledge Base
Published Sep. 10, 2025

Service builder upgrade issue related to class: "java.lang.ClassNotFoundException: com.liferay.portal.kernel.service.PersistedModelLocalServiceRegistry cannot be found by com.mchi.master.service.service_1.0.0"

Written By

Rishabh Agrawal

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

Issue

  • ClassNotFoundException error while upgrading the Service builder of DXP 7.2 to DXP 7.4 2023 Q4.0.
  • The error looks like this:
    2024-01-18 09:31:22.491 ERROR [Refresh Thread: Equinox Container: 7c691475-51d0-4491-a1a2-40bee687e2d2][ModuleApplicationContextExtender:72] null
    java.lang.ClassNotFoundException: com.liferay.portal.kernel.service.PersistedModelLocalServiceRegistry cannot be found by com.mchi.master.service.service_1.0.0

Environment

  • Liferay DXP 7.4 2023 Q4

Resolution

Below are the steps that should be followed:

    1. Use the class "ServiceTrackerMap" instead of "PersistedModelLocalServiceRegistry" based on LPS-199563.
    2. The tags for Quarterly Releases are not yet added in Liferay Developer Studio (LDS), hence select 'dxp-7.4-u102' from the dropdown of the product version.
    3. The ServiceTrackerMap is used to track services, but not to register them. ServiceTrackerMap is essentially the same as ServiceTracker with the difference that ServiceTrackerMap allows to be able to categorize the services based on a property.
    4. For the specific use case, we don’t have to even know about ServiceTrackerMap since there is a utility class that abstracts all that information, see https://github.com/liferay/liferay-portal/blob/eb207a1de06962b270c82900e178f3d6b5ef5dcf/portal-impl/src/com/liferay/portal/service/PersistedModelLocalServiceRegistryUtil.java so if the users want to retrieve a service based on a specific model.class.name, they just need to execute: "PersistedModelLocalServiceRegistryUtil.getPersistedModelLocalService(modelClassName);".
    5. If users want to register a new PersistedModelLocalService they may define a @Component or may inline the registration of the service like:
      _serviceRegistration = bundleContext.registerService(
      PersistedModelLocalService.class,
      customServiceObject,
      MapUtil.singletonDictionary("model.class.name", CustomService.class.getName()));
  • 6. In case you face errors related to Impl, kindly change the version to 9.0.4 in com.liferay.gradle.plugins.workspace in settings.gradle
    7. Delete the src/main/java directory from your module and refresh Gradle.
    8. In settings.gradle, change the version of the dependencies classpath to "9.1.1", like: "classpath(group: "com.liferay", name: "com.liferay.gradle.plugins.workspace", version: "9.1.1")".

    9. If the users are encountering errors for the versions they are trying, they can delete the src/main/java file, refresh the service, and then try again with the different versions until the build is successful.
Did this article resolve your issue ?

Legacy Knowledge Base