掲示板
Reindexing custom class - [DynamicQueryFactoryImpl:96] Unable find model
9年前 に Jan Tošovský によって更新されました。
Reindexing custom class - [DynamicQueryFactoryImpl:96] Unable find model
Liferay Master 投稿: 566 参加年月日: 10/07/22 最新の投稿
Dear All,
I've created two custom entities using a service builder. It is similar to WIKI node with multiple pages.
In the custom indexer there is overridden internal class WebHelpPageActionableDynamicQuery() which is executed during (re)indexing:
My plugin is deployed outside the ROOT context and it is most likely the reason of the following error:
But it is not clear to me how this kind of indexing is supposed to work. When actionableDynamicQuery.performActions() method (from my portlet) is executed, it calls BaseActionableDynamicQuery which is 'somehow' working again with my classes which are unknown to it.
Is there any example portlet utilizing indexing? My code is based on WIKI portlet where this context mixture is not the case. How can I deal with it properly?
Thanks, Jan
I've created two custom entities using a service builder. It is similar to WIKI node with multiple pages.
In the custom indexer there is overridden internal class WebHelpPageActionableDynamicQuery() which is executed during (re)indexing:
protected void reindexPages(long companyId, long groupId, final long documentId) throws PortalException, SystemException {
LOGGER.info("Reindex pages: " + documentId);
ActionableDynamicQuery actionableDynamicQuery = new WebHelpPageActionableDynamicQuery() {
@Override
protected void addCriteria(DynamicQuery dynamicQuery) {
LOGGER.info("Adding a criteria: " + documentId);
Property documentIdProperty = PropertyFactoryUtil.forName("documentId");
dynamicQuery.add(documentIdProperty.eq(documentId));
}
@Override
protected void performAction(Object object) throws PortalException {
WebHelpPage page = (WebHelpPage) object;
if (page != null) {
LOGGER.info("pageTitle" + page.getTitle());
}
addDocument(getDocument(page));
}
};
actionableDynamicQuery.setCompanyId(companyId);
actionableDynamicQuery.setGroupId(groupId);
actionableDynamicQuery.setSearchEngineId(getSearchEngineId());
actionableDynamicQuery.performActions();
}
My plugin is deployed outside the ROOT context and it is most likely the reason of the following error:
15:04:07,056 ERROR [http-bio-8080-exec-2][DynamicQueryFactoryImpl:96] Unable find model com.liferay.portlet.webhelp.model.impl.WebHelpPageImpl
java.lang.ClassNotFoundException: com.liferay.portlet.webhelp.model.impl.WebHelpPageImpl
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at com.liferay.portal.dao.orm.hibernate.DynamicQueryFactoryImpl.getImplClass(DynamicQueryFactoryImpl.java:125)
at com.liferay.portal.dao.orm.hibernate.DynamicQueryFactoryImpl.getImplClass(DynamicQueryFactoryImpl.java:92)
at com.liferay.portal.dao.orm.hibernate.DynamicQueryFactoryImpl.forClass(DynamicQueryFactoryImpl.java:47)
at com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil.forClass(DynamicQueryFactoryUtil.java:31)
at com.liferay.portal.kernel.dao.orm.BaseActionableDynamicQuery.performActionsInSingleInterval(BaseActionableDynamicQuery.java:298)
at com.liferay.portal.kernel.dao.orm.BaseActionableDynamicQuery.performActions(BaseActionableDynamicQuery.java:45)
at com.liferay.portlet.webhelp.util.WebHelpPageIndexer.reindexPages(WebHelpPageIndexer.java:297)
at com.liferay.portlet.webhelp.util.WebHelpPageIndexer$1.performAction(WebHelpPageIndexer.java:260)
at com.liferay.portal.kernel.dao.orm.BaseActionableDynamicQuery.performActionsInSingleInterval(BaseActionableDynamicQuery.java:309)
at com.liferay.portal.kernel.dao.orm.BaseActionableDynamicQuery.performActions(BaseActionableDynamicQuery.java:45)
at com.liferay.portlet.webhelp.util.WebHelpPageIndexer.reindexDocuments(WebHelpPageIndexer.java:265)
at com.liferay.portlet.webhelp.util.WebHelpPageIndexer.doReindex(WebHelpPageIndexer.java:242)
at com.liferay.portal.kernel.search.BaseIndexer.reindex(BaseIndexer.java:457)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
But it is not clear to me how this kind of indexing is supposed to work. When actionableDynamicQuery.performActions() method (from my portlet) is executed, it calls BaseActionableDynamicQuery which is 'somehow' working again with my classes which are unknown to it.
Is there any example portlet utilizing indexing? My code is based on WIKI portlet where this context mixture is not the case. How can I deal with it properly?
Thanks, Jan
9年前 に Jan Tošovský によって更新されました。
RE: Reindexing custom class - [DynamicQueryFactoryImpl:96] Unable find mode
Liferay Master 投稿: 566 参加年月日: 10/07/22 最新の投稿
The most strange thing is requirement of my custom Impl class by DynamicQueryFactoryUtil. It is not part of my custom service (which is located in lib/ext folder), hence unreachable by the specified class loader in WebHelpPageActionableDynamicQuery class:
In this particular case I'll try to use portal classloader instead, but I'd rather avoid those Impl calls if possible. Can I influence this?
Thanks, Jan
com.liferay.portlet.webhelp.service.ClpSerializer.class.getClassLoader()
In this particular case I'll try to use portal classloader instead, but I'd rather avoid those Impl calls if possible. Can I influence this?
Thanks, Jan
9年前 に Jan Tošovský によって更新されました。
RE: Reindexing custom class - [DynamicQueryFactoryImpl:96] Unable find mode
Liferay Master 投稿: 566 参加年月日: 10/07/22 最新の投稿
9年前 に Jan Tošovský によって更新されました。
RE: Reindexing custom class - [DynamicQueryFactoryImpl:96] Unable find mode (回答)
Liferay Master 投稿: 566 参加年月日: 10/07/22 最新の投稿
I've found a workaround using the following code:
It prefers portlet classLoader over default one.
HTH, Jan
ClassLoader classLoader = (ClassLoader) PortletBeanLocatorUtil.locate(ClpSerializer.getServletContextName(), "portletClassLoader");
actionableDynamicQuery.setClassLoader(classLoader);
It prefers portlet classLoader over default one.
HTH, Jan
7年前 に Sumanth Kulkarni によって更新されました。
RE: Reindexing custom class - [DynamicQueryFactoryImpl:96] Unable find mode
New Member 投稿: 2 参加年月日: 15/02/20 最新の投稿
Below code will resolve DynamicQueryFactoryImpl:100] Unable find model
ClassLoader cl = Reciprocal.class.getClassLoader();
DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Reciprocal.class, cl);
Projection projection = ProjectionFactoryUtil.distinct(ProjectionFactoryUtil.property("state"));
dynamicQuery.add(PropertyFactoryUtil.forName("country").eq("Malaysia"));
dynamicQuery.setProjection(projection);
List<Object> stateList = ReciprocalLocalServiceUtil.dynamicQuery(dynamicQuery);
ClassLoader cl = Reciprocal.class.getClassLoader();
DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Reciprocal.class, cl);
Projection projection = ProjectionFactoryUtil.distinct(ProjectionFactoryUtil.property("state"));
dynamicQuery.add(PropertyFactoryUtil.forName("country").eq("Malaysia"));
dynamicQuery.setProjection(projection);
List<Object> stateList = ReciprocalLocalServiceUtil.dynamicQuery(dynamicQuery);