Issue
- Upgrading from Liferay DXP 7.3 to 7.4 can found issues with a custom module that overrides jsp files and uses the Core Registry API (https://help.liferay.com/hc/en-us/articles/360018162831-Using-OSGi-Services-from-EXT-Plugins), which has been removed in Liferay 7.4.
- This article describes the possible alternative to use a custom OSGi service from the overridden JSP
Environment
- 2024.Q3
Resolution
-
Registry API has been removed in Liferay 7.4 -> Documentation .The mentioned alternative would be based on using the SystemBundleUtil.java class.
- An example of using the LDAPUserImporter class in a Groovy script is provided:
Use for Liferay 7.3
import com.liferay.registry.RegistryUtil;
import com.liferay.portal.security.ldap.exportimport.LDAPUserImporter;
def registry = RegistryUtil.getRegistry();
def ldapUserImporter= registry.getService(registry.getServiceReference(LDAPUserImporter.class));
[...]
Use for 7.4
import com.liferay.portal.kernel.module.util.SystemBundleUtil;
import org.osgi.framework.BundleContext;
import com.liferay.portal.security.ldap.exportimport.LDAPUserImporter;
BundleContext bundleContext = SystemBundleUtil.getBundleContext();
def ldapUserImporter = bundleContext.getService(bundleContext.getServiceReference(LDAPUserImporter.class));
[...]
NOTE: The following resolution requires customization and should only be implemented at the discretion of your team. Liferay Support will not be able to assist with designing or implementing customizations.