Legacy Knowledge Base
Published Sep. 10, 2025

Running script to import Result Rankings data fails

Written By

Tony Ng

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

startup failed:
Script1.groovy: 3: unable to resolve class com.liferay.registry.Registry
@ line 3, column 1.
import com.liferay.registry.Registry;
^

Script1.groovy: 4: unable to resolve class com.liferay.registry.RegistryUtil
@ line 4, column 1.
import com.liferay.registry.RegistryUtil;
^

Script1.groovy: 1: unable to resolve class com.liferay.portal.instances.service.PortalInstancesLocalService
@ line 1, column 1.
import com.liferay.portal.instances.service.PortalInstancesLocalService;
^

3 errors

Line 1: import com.liferay.portal.instances.service.PortalInstancesLocalService;
Line 2: import com.liferay.portal.search.tuning.rankings.storage.RankingsDatabaseImporter;
Line 3: import com.liferay.registry.Registry;
Line 4: import com.liferay.registry.RegistryUtil;
Line 5:
Line 6: Registry registry = RegistryUtil.getRegistry();
Line 7:
Line 8: PortalInstancesLocalService portalInstancesLocalService = registry.getServices(PortalInstancesLocalService.class, null)[0];
Line 9: RankingsDatabaseImporter rankingsDatabaseImporter = registry.getServices(RankingsDatabaseImporter.class, null)[0];
Line 10:
Line 11: for (long companyId : portalInstancesLocalService.getCompanyIds()) {
Line 12: rankingsDatabaseImporter.populateDatabase(companyId);
Line 13: }

 

Environment

  • 2025.Q1

Resolution

  • Run the following script instead:
import com.liferay.portal.kernel.module.util.SystemBundleUtil
import com.liferay.portal.kernel.util.PortalUtil
import com.liferay.portal.search.tuning.rankings.storage.RankingsDatabaseImporter

import org.osgi.framework.BundleContext
import org.osgi.util.tracker.ServiceTracker

BundleContext bundleContext = SystemBundleUtil.getBundleContext();

ServiceTracker rankingsDatabaseImporterTracker = new ServiceTracker(
  bundleContext, RankingsDatabaseImporter.class.getName(), null
)

try {
    rankingsDatabaseImporterTracker.open()

    RankingsDatabaseImporter rankingsDatabaseImporter = (RankingsDatabaseImporter) rankingsDatabaseImporterTracker.getService()

for (long companyId : PortalUtil.getCompanyIds()) {
rankingsDatabaseImporter.populateDatabase(companyId);
}
} finally {
  rankingsDatabaseImporterTracker.close()
}
  • Enabling INFO logging for com.liferay.portal.search.tuning.rankings.web.internal.storage.RankingsDatabaseImporterImpl before running the script is recommended.

Additional Information

 

 

Did this article resolve your issue ?

Legacy Knowledge Base