0

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

1 Answers1

0

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.

Olaf Kock
  • 46,930
  • 8
  • 59
  • 90
  • @Ahmed Olaf is actually saying that there is a timing issue ... when you invoke the static util class the internal Java proxy has not been completely initialized ...when injecting it with osgi, the environment takes care of these kind of things – André Jul 06 '20 at 19:55