I am trying to get all Dynamic Data List (DDL) from Liferay DXP 7.0.2 GA3 but after I using that code to get all the DDL
List<DDLRecordSet> ddlList = DDLRecordSetLocalServiceUtil.getDDLRecordSets(
com.liferay.portal.kernel.dao.orm.QueryUtil.ALL_POS,
com.liferay.portal.kernel.dao.orm.QueryUtil.ALL_POS);
I got an error saying
com.sun.proxy.$Proxy439 cannot be cast to com.liferay.dynamic.data.lists.service.DDLRecordSetLocalService
Java JDK: 1.8.0_251
Gradle Version: 5.6.4
Java Home: C:\Program Files\Java\jdk1.8.0_251
Instead of using
DDLRecordSetLocalServiceUtil(the old compatibility class with static methods) you should have the service injected by OSGi, through@Reference.This can only be done in a
@Component, but makes it a lot clearer that your code is only called when all the dependencies are properly wired.But before you do this, you'll need to upgrade to GA7 and patch. Later, ideally upgrade further and stay on the current version.