Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Leo Pratlong
[solved] Maven portlet - need object from portal-impl . How to do that?
July 21, 2011 3:27 AM
Answer

Leo Pratlong

Rank: Expert

Posts: 362

Join Date: July 6, 2010

Recent Posts

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:
1final DynamicQuery query = DynamicQueryFactoryUtil.forClass(DLFileEntry.class)
2                .add(PropertyFactoryUtil.forName("companyId").eq(groupId))
3                .addOrder(OrderFactoryUtil.desc("createDate"));
4        final List<DLFileEntry> fileEntries = (List<DLFileEntry>) DLFileEntryLocalServiceUtil.dynamicQuery(query, 0, 5);



A ClassNotFoundException occurs in the forClass(DLFileEntry.class) :
109:06:25,175 ERROR [DynamicQueryFactoryImpl:83] Unable find model com.liferay.portlet.documentlibrary.model.impl.DLFileEntryImpl
2java.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
Philippe CHEIPE
RE: Maven portlet - need object from portal-impl . How to do that?
July 21, 2011 3:05 AM
Answer

Philippe CHEIPE

Rank: Junior Member

Posts: 61

Join Date: August 12, 2010

Recent Posts

Yes, we do the same and had the same problem.

Solution is to pass in a classloader like this:

1ClassLoader cl = PortalClassLoaderUtil.getClassLoader();
2DynamicQuery dqi =    DynamicQueryFactoryUtil.forClass(JournalArticle.class, cl);
3Criterion crit = PropertyFactoryUtil.forName("uuid").eq(uuid);
4dqi.add(crit);
5List<Object> articles = JournalArticleLocalServiceUtil.dynamicQuery(dqi);

See http://issues.liferay.com/browse/LPS-2534

Thanks to Gary of my team ;)
Leo Pratlong
RE: Maven portlet - need object from portal-impl . How to do that?
July 21, 2011 3:18 AM
Answer

Leo Pratlong

Rank: Expert

Posts: 362

Join Date: July 6, 2010

Recent Posts

Greeeeeattttt!

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

And thanks to Gary emoticon.