Fórum

Dynamic Query + Unable to find Model

thumbnail
Tina Agrawal, modificado 12 Anos atrás.

Dynamic Query + Unable to find Model

Expert Postagens: 297 Data de Entrada: 03/01/08 Postagens Recentes
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, modificado 12 Anos atrás.

RE: Dynamic Query + Unable to find Model

Liferay Legend Postagens: 1449 Data de Entrada: 10/10/07 Postagens Recentes
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, modificado 12 Anos atrás.

RE: Dynamic Query + Unable to find Model

Expert Postagens: 297 Data de Entrada: 03/01/08 Postagens Recentes
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, modificado 12 Anos atrás.

RE: Dynamic Query + Unable to find Model

New Member Postagens: 6 Data de Entrada: 27/09/11 Postagens Recentes
Thanks a lot Tina,
third solution is working successfully which is..

ClassLoader classLoader = (ClassLoader)PortletBeanLocatorUtil.locate(ClpSerializer.SERVLET_CONTEXT_NAME,"portletClassLoader");
asif aftab, modificado 8 Anos atrás.

RE: Dynamic Query + Unable to find Model

Regular Member Postagens: 123 Data de Entrada: 02/09/13 Postagens Recentes
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.