Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call a custom service from other plugins in liferay?

I have a Liferay Custom service built using service builder. I have the WebArticleLocalHelperServiceImpl which is the implementation of my service.

How can I call my service from other plugin projects.

I am able to call the service from velocity template projects using:

// get the service using servicelocator.
#set ($myService = $serviceLocator.findService('my-services-portlet', 'com.mycompany.service.MyService'))

// then call the service method    
#set ($result = $myService.mymethod())

I am able to call the service from velocity templates, but I am not able to call the service from other plugin projects (Portlets)

when I call ServiceLocator from MVCPortlet, it says ClassNotFound.

What is the proper way to call the *serviceImpl from MVCPortlet?

I searched liferay forums too regarding this, but none of the solutions worked for me.

Thanks a lot in advance.

like image 775
Rajesh Pantula Avatar asked Mar 21 '12 11:03

Rajesh Pantula


1 Answers

When you run servicebuilder, you get a *-service.jar (where * is the name for your project/service). You need to make this jar available to the plugin you want to call it from. You can do this either by declaring a dependency (liferay-plugin-package.properties), manually copying it to that plugin or by placing it on the global classpath

like image 193
Olaf Kock Avatar answered Sep 21 '22 18:09

Olaf Kock