Foros de discusión

Dynamic Query + Unable to find Model

thumbnail
Tina Agrawal, modificado hace 12 años.

Dynamic Query + Unable to find Model

Expert Mensajes: 297 Fecha de incorporación: 3/01/08 Mensajes recientes
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 hace 12 años.

RE: Dynamic Query + Unable to find Model

Liferay Legend Mensajes: 1449 Fecha de incorporación: 10/10/07 Mensajes recientes
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 hace 12 años.

RE: Dynamic Query + Unable to find Model

Expert Mensajes: 297 Fecha de incorporación: 3/01/08 Mensajes recientes
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 hace 12 años.

RE: Dynamic Query + Unable to find Model

New Member Mensajes: 6 Fecha de incorporación: 27/09/11 Mensajes recientes
Thanks a lot Tina,
third solution is working successfully which is..

ClassLoader classLoader = (ClassLoader)PortletBeanLocatorUtil.locate(ClpSerializer.SERVLET_CONTEXT_NAME,"portletClassLoader");
asif aftab, modificado hace 8 años.

RE: Dynamic Query + Unable to find Model

Regular Member Mensajes: 123 Fecha de incorporación: 2/09/13 Mensajes recientes
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.