Foren

Dynamic Query + Unable to find Model

thumbnail
Tina Agrawal, geändert vor 12 Jahren.

Dynamic Query + Unable to find Model

Expert Beiträge: 297 Beitrittsdatum: 03.01.08 Neueste Beiträge
Hi All,

I have a Plugins Portlet and the portlet has its own services defined. Since I needed these services in various other portlets i moved the portlet-service.jar to global lib directory.
But now the issue is when LocalServiceImpl for the same portlet tries using Dynamic Query it throws an error saying "Unable find model ".

Any clues will be really helpful.

Regards,
Tina Agrawal
thumbnail
Thiago Leão Moreira, geändert vor 12 Jahren.

RE: Dynamic Query + Unable to find Model

Liferay Legend Beiträge: 1449 Beitrittsdatum: 10.10.07 Neueste Beiträge
Hey Tina,

Are you getting a ClassNotFoundException, right? If it true, you should pass the context name of your service when invoking the forClass method

DynamicQueryFactoryUtil.forClass(Book.class, "book-portlet");


Hope this helps
thumbnail
Tina Agrawal, geändert vor 12 Jahren.

RE: Dynamic Query + Unable to find Model

Expert Beiträge: 297 Beitrittsdatum: 03.01.08 Neueste Beiträge
Thanks Thiago.

I referred to this link -
DynamicQuery API and ClassLoaders in Liferay

The third one - The implementation class is in another portlet, solved my issue.

Regards,
Tina Agrawal
Satish Sapate, geändert vor 12 Jahren.

RE: Dynamic Query + Unable to find Model

New Member Beiträge: 6 Beitrittsdatum: 27.09.11 Neueste Beiträge
Thanks a lot Tina,
third solution is working successfully which is..

ClassLoader classLoader = (ClassLoader)PortletBeanLocatorUtil.locate(ClpSerializer.SERVLET_CONTEXT_NAME,"portletClassLoader");
asif aftab, geändert vor 8 Jahren.

RE: Dynamic Query + Unable to find Model

Regular Member Beiträge: 123 Beitrittsdatum: 02.09.13 Neueste Beiträge
ClassLoader classLoader = (ClassLoader)PortletBeanLocatorUtil.locate(ClpSerializer.SERVLET_CONTEXT_NAME,"portletClassLoader");
I am getting error here, SERVLET_CONTEXT_NAME is not defined, so I use
DynamicQueryFactoryUtil.forClass(Book.class, "book-portlet");
instead of "book-portlet" I gave my portlet name, e.g. "use-search-portlet" and it works.
Thanks for all.