Foren

[solved] Maven portlet - need object from portal-impl . How to do that?

thumbnail
Leo PRATLONG, geändert vor 12 Jahren.

[solved] Maven portlet - need object from portal-impl . How to do that?

Expert Beiträge: 363 Beitrittsdatum: 06.07.10 Neueste Beiträge
Hi,
I am developping a Struts portlet for liferay 6.0.6 CE. I do not use Liferay SDK and I build my portlet with Maven.
This portlet display the last files uploaded to the DocumentLibrary. I use a dynamicQuery to retrieve the FileEntries.

Here is a piece of code:
final DynamicQuery query = DynamicQueryFactoryUtil.forClass(DLFileEntry.class)
                .add(PropertyFactoryUtil.forName("companyId").eq(groupId))
                .addOrder(OrderFactoryUtil.desc("createDate"));
        final List<dlfileentry> fileEntries = (List<dlfileentry>) DLFileEntryLocalServiceUtil.dynamicQuery(query, 0, 5);</dlfileentry></dlfileentry>



A ClassNotFoundException occurs in the forClass(DLFileEntry.class) :
09:06:25,175 ERROR [DynamicQueryFactoryImpl:83] Unable find model com.liferay.portlet.documentlibrary.model.impl.DLFileEntryImpl
java.lang.ClassNotFoundException: com.liferay.portlet.documentlibrary.model.impl.DLFileEntryImpl


I understand that DLFileEntryImpl is in portal-impl, but I do not want to add a dependency to it in my pom.xml (because it will not work with "scope provided").
So I tried to move this piece of code in a jar that I put in a plugin EXT, in the ext-lib/global. But, my jar haven't access to portal-impl in the lib/ext folder too. So, ClassNotFoundException occurs again.
NB: my plugin EXT is made with Liferay SDK. I still have not succeeded to make it with Maven.

I can not move the DynamicQuery in the portal-impl part of my EXT because it will not be available for my portlet and, because there is no dependency for it in my maven pom.xml, my portlet will not built.

So, does anybody have a solution please? I think a solution should be to make a plugin EXT with Maven, no?

I hope I was understandable emoticon.
Thx for your help.

Leo
thumbnail
Philippe CHEIPE, geändert vor 12 Jahren.

RE: Maven portlet - need object from portal-impl . How to do that?

Junior Member Beiträge: 61 Beitrittsdatum: 12.08.10 Neueste Beiträge
Yes, we do the same and had the same problem.

Solution is to pass in a classloader like this:

ClassLoader cl = PortalClassLoaderUtil.getClassLoader();
DynamicQuery dqi =	DynamicQueryFactoryUtil.forClass(JournalArticle.class, cl);
Criterion crit = PropertyFactoryUtil.forName("uuid").eq(uuid);
dqi.add(crit);
List<object> articles = JournalArticleLocalServiceUtil.dynamicQuery(dqi);<br>See http://issues.liferay.com/browse/LPS-2534<br><br>Thanks to Gary of my team ;)</object>
thumbnail
Leo PRATLONG, geändert vor 12 Jahren.

RE: Maven portlet - need object from portal-impl . How to do that?

Expert Beiträge: 363 Beitrittsdatum: 06.07.10 Neueste Beiträge
Greeeeeattttt!

Thanks a lot! It's exactly what I need!

And thanks to Gary emoticon.