3/16/2011

Liferay: Portlets accessing Services of other portlets

Just a quick tip:


When you develop portlets you will put most of the generated services in your portlets. So you run the Service Builder, develop your business code and deploy it. Everything´s fine.


But what do you do if another portlet wants to access your service ? Say for  example that portlet A allows you to enter data of users and portlet B displays all users. The service is located in Portlet A and you shouldn´t create a new one in Portlet B.


The solution is simple: Generate your service, and put the resulting xx-portlet-service.jar into your application servers lib dir. 


In Tomcat its (for example): \lib.


Be sure to remove the service jar from Portlet Bs WEB-INF/lib directory !!!
Now restart your server and Portlet B should be able to access all service classes from Portlet A, including the XXLocalServiceUtil.




If you like this tutorial it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)

If you have any questions, feel free to leave a comment.