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
RE: Liferay 7.1 Custom web content search
I have a custom search application originally developed for LR 6.2. It also worked with 7.0 but there are changes in 7.1 that cause a problem searching web content (journal articles). This is a result of the TITLE and DESCRIPTION fields being taken out of the JOURNALARTICLE table and moved into JOURNALARTICLELOCALIZATION. The original search code can't search on those fields now, so I added some code to search the new table:
ClassLoader cl = PortalClassLoaderUtil.getClassLoader();
DynamicQuery q = DynamicQueryFactoryUtil.forClass(JournalArticleLocalization.class, cl);
The code builds but unfortunately, an exception is thrown at that second line:2019-03-12 19:24:26.376 ERROR [http-nio-8080-exec-2][DynamicQueryFactoryImpl:107] Unable find model com.liferay.journal.model.impl.JournalArticleLocalizationImpl
java.lang.ClassNotFoundException: com.liferay.journal.model.impl.JournalArticleLocalizationImpl
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1275)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1104)
at com.liferay.portal.dao.orm.hibernate.DynamicQueryFactoryImpl.getImplClass(DynamicQueryFactoryImpl.java:129)
at com.liferay.portal.dao.orm.hibernate.DynamicQueryFactoryImpl.getImplClass(DynamicQueryFactoryImpl.java:95)
at com.liferay.portal.dao.orm.hibernate.DynamicQueryFactoryImpl.forClass(DynamicQueryFactoryImpl.java:45)
at com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil.forClass(DynamicQueryFactoryUtil.java:29)
at gov.nasa.hq.liferay.search.journal.JournalSearch.getArticlesLocalized(JournalSearch.java:576)
I can see that the class in question (JournalArticleLocalizationImpl) is in the journal-service module, I don't understand why this exception is thrown.
hm...normally you would get the dynamicQuery using the localservice like this https://community.liferay.com/forums/-/message_boards/message/88776488. However it looks like JournalArticleLocalization doesn't have a localService...
I'm not sure what your query involves, but if you could do an index search that would probably best. (And write a indexPostProcessor to index more fields from any joins you need)
If you need a short term solution, I think you'll need to get the classloader for the journal-service module which I think is available in ClassLoaderPool or ServletContextClassLoaderPool. This should be avoided if possible though.
I'm not sure what your query involves, but if you could do an index search that would probably best. (And write a indexPostProcessor to index more fields from any joins you need)
If you need a short term solution, I think you'll need to get the classloader for the journal-service module which I think is available in ClassLoaderPool or ServletContextClassLoaderPool. This should be avoided if possible though.
I went with the simplest solution, look up the datasource using JNDI and write a simple SQL query to query the localization table. This is not ideal and it would certainly be preferable if the Liferay API provided the local service classes for that table.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™