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
Liferay 7.2- Alternative to ClpSerializer
I have created a service builder module and I have also successfully integrated with my portlet module.
Now I am trying to execute a DynamicQuery and I am getting an ClassNofFoundException error. He cant found my packagename.model.impl.EntityImpl.
I am doing my query like this:
I have seen that this should be a classLoader problem and the solution should be using the ClpSerializer class:
But my service builder didn't generate this class. If I understand correctly, it doesn't generated anymore. So, is there any alternative to the ClpSerializer? How should I use the classLoader to execute the query correctly?
Now I am trying to execute a DynamicQuery and I am getting an ClassNofFoundException error. He cant found my packagename.model.impl.EntityImpl.
I am doing my query like this:
DynamicQuery query = DynamicQueryFactoryUtil.forClass(Entity.class, Entity.class.getClassLoader());
query.add(PropertyFactoryUtil.forName("userId").eq((int) theme.getLayout().getUserId()));
List<Entity> entities = EntityLocalServiceUtil.dynamicQuery(query);
I have seen that this should be a classLoader problem and the solution should be using the ClpSerializer class:
ClassLoader classLoader = (ClassLoader) PortletBeanLocatorUtil.locate(ClpSerializer.SERVLET_CONTEXT_NAME, "portletClassLoader");
But my service builder didn't generate this class. If I understand correctly, it doesn't generated anymore. So, is there any alternative to the ClpSerializer? How should I use the classLoader to execute the query correctly?
Hi,
Try using this
DynamicQuery query = EntityLocalServiceUtil.dynamicQuery();
query.add(PropertyFactoryUtil.forName("userId").eq((int) theme.getLayout().getUserId()));
List<Entity> entities = EntityLocalServiceUtil.dynamicQuery(query);
Try using this
DynamicQuery query = EntityLocalServiceUtil.dynamicQuery();
query.add(PropertyFactoryUtil.forName("userId").eq((int) theme.getLayout().getUserId()));
List<Entity> entities = EntityLocalServiceUtil.dynamicQuery(query);
Hi Mohammed,
Your way is working perfectly. Thank you very much!
Your way is working perfectly. Thank you very much!
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™