Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Aleix Casagolda -
Problem adding search capabilities to a portlet
May 22, 2009 1:47 AM
Answer

Aleix Casagolda -

Rank: New Member

Posts: 20

Join Date: May 18, 2009

Recent Posts

Hi, I'm developing a portlet using Liferay 5.2.

I need that the information from the portlet could be searchable from search portlets so I have implemented a Indexer class and a OpenSearch class extending the HitsOpenSearchImpl as I've seen in the wiki.

My problem is that it has to be deployed as a plugin and in that case, I get a ClassNotFoundException because from the war portlet it seems that I can't see the class HitsOpenSearchImpl.

Is there any other way to do this? Thanks in advance!
Stef Heyenrath
RE: Problem adding search capabilities to a portlet
June 19, 2009 8:35 AM
Answer

Stef Heyenrath

Rank: Junior Member

Posts: 76

Join Date: December 3, 2008

Recent Posts

Hi Aleix,

I've run into the same problem. I guess the solution is to develop this search in the 'ext' environment ?

Did you find a solution for this?
Tomas Polesovsky
RE: Problem adding search capabilities to a portlet
June 19, 2009 12:33 PM
Answer

Tomas Polesovsky

LIFERAY STAFF

Rank: Liferay Master

Posts: 586

Join Date: February 13, 2009

Recent Posts

Hi,

just create liferay-plugin-package.properties in your WEB-INF folder (if you don't have one yet) and define, which Liferay jars you need to copy from Liferay. Liferay will copy these jars in the deploy process.

1
2portal.dependency.jars=\
3    portal-impl.jar


For more try google liferay-plugin-package.properties or portal.dependency.jars.

Check also this thread please: http://www.liferay.com/web/guest/community/forums/-/message_boards/message/2441653
Stef Heyenrath
RE: Problem adding search capabilities to a portlet
June 20, 2009 12:00 AM
Answer

Stef Heyenrath

Rank: Junior Member

Posts: 76

Join Date: December 3, 2008

Recent Posts

Hi Tomas,

What I actually want to do is :
Develop the services + indexer + opensearchimpl in the EXT environment and use these services in a portlet outside the ext environment. This because I want to bundle all Services, indexers and searchers in one place so that multiple portlets can use these.

EXT is as follows:



And my liferay-portlet.xml looks like this:
1<liferay-portlet-app>
2    <portlet>
3        <portlet-name>mybook</portlet-name>
4        <icon>/icon.png</icon>
5        <indexer-class>com.ext.tencompetence.services.util.MyBookIndexer</indexer-class>
6        <open-search-class>com.ext.tencompetence.services.util.MyBookOpenSearchImpl</open-search-class>
7        <instanceable>true</instanceable>
8       . . . . .


And my liferay-plugin-package.properties looks like this:
 1name=MyBook Test
 2module-group-id=liferay
 3module-incremental-version=1
 4tags=
 5short-description=
 6change-log=
 7page-url=http://www.liferay.com
 8author=Liferay, Inc.
 9licenses=MIT
10
11[b]portal.dependency.jars=ext-impl.jar[/b][color=#2729CA][/color]


But when deploying my portlet I get this exception:
java.lang.NoClassDefFoundError: com/liferay/portal/search/HitsOpenSearchImpl


I've read the link you posted and I understand, but that brings me back to my original question:
Services + indexer + opensearchimpl in the EXT environment and a portlet outside the ext environment.

It seems that this is not possible, i this correct ?
So the solution would be to develop all portlets in the ext environment?

Please advice.
Tomas Polesovsky
RE: Problem adding search capabilities to a portlet
June 20, 2009 6:03 AM
Answer

Tomas Polesovsky

LIFERAY STAFF

Rank: Liferay Master

Posts: 586

Join Date: February 13, 2009

Recent Posts

Hi Stef,

nice picture emoticon

After reading your post at least 8-times I finally understand what's going on emoticon

I suppose that liferay-plugin-package.properties and liferay-portlet.xml are in your portlet application, am I right?

NoClassDefFoundError - it seems that MyBookOpenSearchImpl doesn't see the HitsOpenSearchImpl class in portal-impl.jar. It implies that classloader that creates new instance of MyBookOpenSearchImpl doesn't see the HitsOpenSearchImpl class. What version of Liferay do you use? Until now I thought that Plugins use the Liferay's PortalClassLoader, but it doesn't seem to be truth - it must be another classloader, because PortalClassLoader DOES see the portal-impl.jar. Quick solution can be adding portal-impl.jar (again emoticon) into portal.dependency.jars.

If you need to solve this you should debug deploy process of Liferay and look into PortletContextListener and PortletHotDeployListener classes.

Or there is still the easy way - do everything in EXT. It doesn't break your precondition:
This because I want to bundle all Services, indexers and searchers in one place so that multiple portlets can use these.


It is up to you, I hope it is a little more clear now.
Aleix Casagolda -
RE: Problem adding search capabilities to a portlet
June 22, 2009 12:29 AM
Answer

Aleix Casagolda -

Rank: New Member

Posts: 20

Join Date: May 18, 2009

Recent Posts

Hi Stef, what I've done:

First of all, I tried to put portal-impl in liferay-plugin-package.properties and initially it worked but later I got problems with class versions using spring + hibernate.

The solution (workaround) that works for me:

From outside the EXT environment you can implement the OpenSearch interface with no problems so I have implemented my BaseOpenSearchImpl (that implements OpenSearch) and HitsOpenSearchImpl (extends BaseOpenSearchImpl). You can use the source code from Liferay with minor modifications.

I know that in this case I'm duplicating the code from the liferay base but as you know, there isn't a good way to acces liferay implementation classes from plugins.
Stef Heyenrath
RE: Problem adding search capabilities to a portlet
June 22, 2009 6:27 AM
Answer

Stef Heyenrath

Rank: Junior Member

Posts: 76

Join Date: December 3, 2008

Recent Posts

@Tomas,
Thanks for the help !
I found this interesting wiki page how to develop in liferay

The solution for me will be this one:
ServiceBuilder + other portlet solution.


@Aleix,
Thanks for the information, that was also some option I had in mind.

At this moment I will postpone the whole automatic searching and continue on building the services itself.
Navin Singh
RE: Problem adding search capabilities to a portlet
September 9, 2012 7:51 PM
Answer

Navin Singh

Rank: New Member

Posts: 8

Join Date: November 14, 2011

Recent Posts

As per you guys' instructions, I was able to successfully implement search indexing and open search on my custom portlet. It indexes my portlet data when running re-index process. But I have problem now, when I try to search, it gives me an exception stating "Error displaying content of type liferay open search... ", any help will be really appreciated.