Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Error while extracting ddmStructures from DDMStructureLocalServiceUtil
Hello everyone,
I am trying to get all ddmStructures from DDMStructureLocalServiceUtil in Liferay 7.2 as follows
List<DDMStructure> ddmStructures =
DDMStructureLocalServiceUtil.getClassStructures(companyId, PortalUtil.getClassNameId(DLFileEntry.class), new StructureStructureKeyComparator(true));
But I am getting below exceptionStacktrace of Exception:-
java.lang.ClassCastException: com.sun.proxy.$Proxy1676 cannot be cast to com.liferay.dynamic.data.mapping.service.DDMStructureLocalService
at com.liferay.dynamic.data.mapping.service.DDMStructureLocalServiceUtil.getService(DDMStructureLocalServiceUtil.java:1285)
at com.liferay.dynamic.data.mapping.service.DDMStructureLocalServiceUtil.getClassStructures(DDMStructureLocalServiceUtil.java:620)
Build.gradle:-
dependencies {
compileOnly group: "biz.aQute.bnd", name: "biz.aQute.bndlib", version: "3.5.0"
compileOnly group: "com.liferay", name: "com.liferay.portal.configuration.metatype", version: "2.0.0"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "4.0.0"
compileOnly group: "com.liferay.portal", name: "com.liferay.util.taglib", version: "2.0.0"
compileOnly group: "javax.portlet", name: "portlet-api", version: "2.0"
compileOnly group: "javax.servlet", name: "javax.servlet-api", version: "3.0.1"
compileOnly group: "jstl", name: "jstl", version: "1.2"
compileOnly group: "org.osgi", name: "osgi.cmpn", version: "6.0.0"
compileInclude group: 'com.liferay', name: 'com.liferay.dynamic.data.mapping.api', version: '3.9.0'}
Can anyone please help me to resolve this issue.
I am trying to get all ddmStructures from DDMStructureLocalServiceUtil in Liferay 7.2 as follows
List<DDMStructure> ddmStructures =
DDMStructureLocalServiceUtil.getClassStructures(companyId, PortalUtil.getClassNameId(DLFileEntry.class), new StructureStructureKeyComparator(true));
But I am getting below exceptionStacktrace of Exception:-
java.lang.ClassCastException: com.sun.proxy.$Proxy1676 cannot be cast to com.liferay.dynamic.data.mapping.service.DDMStructureLocalService
at com.liferay.dynamic.data.mapping.service.DDMStructureLocalServiceUtil.getService(DDMStructureLocalServiceUtil.java:1285)
at com.liferay.dynamic.data.mapping.service.DDMStructureLocalServiceUtil.getClassStructures(DDMStructureLocalServiceUtil.java:620)
Build.gradle:-
dependencies {
compileOnly group: "biz.aQute.bnd", name: "biz.aQute.bndlib", version: "3.5.0"
compileOnly group: "com.liferay", name: "com.liferay.portal.configuration.metatype", version: "2.0.0"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "4.0.0"
compileOnly group: "com.liferay.portal", name: "com.liferay.util.taglib", version: "2.0.0"
compileOnly group: "javax.portlet", name: "portlet-api", version: "2.0"
compileOnly group: "javax.servlet", name: "javax.servlet-api", version: "3.0.1"
compileOnly group: "jstl", name: "jstl", version: "1.2"
compileOnly group: "org.osgi", name: "osgi.cmpn", version: "6.0.0"
compileInclude group: 'com.liferay', name: 'com.liferay.dynamic.data.mapping.api', version: '3.9.0'}
Can anyone please help me to resolve this issue.
Is that at compile time? If you're not getting a compile time error it's probably not a problem with your dependency management. I believe you'll be best served by getting and calling the injected service rather than using the static service util. In the Declarative Services world of Liferay 7.2 it's done using an @Reference annotation:
@Reference
private DDMStructureLocalService _ddmStructureLocalService;
However, looking at your dependencies, I think it's strange that you're depending on version 3.9.0 of the DDM API. I was just looking at another post regarding the DDM API on 7.2, and the version is 5.2.0. So those are a couple of things worth looking into.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™