Forums de discussion
How to access portal specific -LocalServiceUtil methods in groovy script
Ashish Ashok, modifié il y a 10 années.
How to access portal specific -LocalServiceUtil methods in groovy script
New Member Publications: 11 Date d'inscription: 18/06/13 Publications récentes
I am currently creating a workflow which includes an action. The scripting language I am using is groovy. I am trying to access my methods from my custom portlet. But it does not seem to work.
So I then tried to go to
Control panel -> Server Administration -> script
In the script I added the above code. Once I run the script I get the following error
Can anyone please explain me how to work on this issue. Thanks in advance.
import com.xxxx.chameleon.service.DummyLocalServiceUtil;
DummyLocalServiceUtil.getJournalTemplate(10180,"MOVIETEMPLATE");
So I then tried to go to
Control panel -> Server Administration -> script
In the script I added the above code. Once I run the script I get the following error
20:49:23,596 ERROR [http-bio-8080-exec-96][EditServerAction:475] startup failed:
Script15.groovy: 1: unable to resolve class com.xxxx.chameleon.service.DummyLocalServiceUtil
@ line 1, column 1.
import com.xxxx.chameleon.service.DummyLocalServiceUtil;
^
1 error
Line 1: import com.xxxx.chameleon.service.DummyLocalServiceUtil;
Line 2: DummyLocalServiceUtil.getJournalTemplate(10180,"MOVIETEMPLATE");
Can anyone please explain me how to work on this issue. Thanks in advance.
Amos Fong, modifié il y a 10 années.
RE: How to access portal specific -LocalServiceUtil methods in groovy scri
Liferay Legend Publications: 2047 Date d'inscription: 07/10/08 Publications récentes
Hi Ashish,
The problem is the groovy script executed by the portal, which is in the portal's classloader. Your service is in your plugin and thus not available to the portal. I'm not sure if it's possible to somehow manipulate the classloader in groovy, but one thing you can do is move your plugin's service.jar (and remove it from your plugin) to the app server's global lib.
The problem is the groovy script executed by the portal, which is in the portal's classloader. Your service is in your plugin and thus not available to the portal. I'm not sure if it's possible to somehow manipulate the classloader in groovy, but one thing you can do is move your plugin's service.jar (and remove it from your plugin) to the app server's global lib.
Mohammad Azharuddin, modifié il y a 7 années.
RE: How to access portal specific -LocalServiceUtil methods in groovy scri
Expert Publications: 492 Date d'inscription: 17/09/12 Publications récentesAmos Fong:
Hi Ashish,
The problem is the groovy script executed by the portal, which is in the portal's classloader. Your service is in your plugin and thus not available to the portal. I'm not sure if it's possible to somehow manipulate the classloader in groovy, but one thing you can do is move your plugin's service.jar (and remove it from your plugin) to the app server's global lib.
Hi All
can some one help me to manipulate the classloader in groovy. I am on LR7
Amos Fong, modifié il y a 7 années.
RE: How to access portal specific -LocalServiceUtil methods in groovy scri
Liferay Legend Publications: 2047 Date d'inscription: 07/10/08 Publications récentes
Hey Mohammed,
Since making this post, I've learned that you could call portlet services using bean locator:
Since making this post, I've learned that you could call portlet services using bean locator:
DummyLocalServiceUtil= com.liferay.portal.kernel.bean.PortletBeanLocatorUtil.locate("chameleon-portlet", "com.xxxx.chameleon.service.DummyLocalServiceUtil");
DummyLocalServiceUtil.addDummy();
Mohammad Azharuddin, modifié il y a 7 années.
RE: How to access portal specific -LocalServiceUtil methods in groovy scri
Expert Publications: 492 Date d'inscription: 17/09/12 Publications récentesAmos Fong:
Hey Mohammed,
Since making this post, I've learned that you could call portlet services using bean locator:DummyLocalServiceUtil= com.liferay.portal.kernel.bean.PortletBeanLocatorUtil.locate("chameleon-portlet", "com.xxxx.chameleon.service.DummyLocalServiceUtil"); DummyLocalServiceUtil.addDummy();
Hi Amos Fong
Thanks for you response . I am getting bean locator not set for servlet context exception . Is that what you have suggested works for OSGI modules as well ..?
Thanks
Azhar
Mohammad Azharuddin, modifié il y a 7 années.
RE: How to access portal specific -LocalServiceUtil methods in groovy scri
Expert Publications: 492 Date d'inscription: 17/09/12 Publications récentes
Also i am able to run below code in my portlet(module) but if i run the same code in groovy i am getting class not found exception
ClassResolverUtil.resolveByPortletClassLoader("com.xxxx.chameleon.service.EntityLocalServiceUtil", "my-services")
Where my service builder module structure is as follows
my-services->my-services-api
>my-services-service
When i try the below suggested method i am getting bean locator exception --> com.liferay.portal.kernel.bean.BeanLocatorException: BeanLocator is not set for servlet context my-services. The below code doesn't even work in the portlet
DummyLocalServiceUtil= com.liferay.portal.kernel.bean.PortletBeanLocatorUtil.locate("my-services", "com.xxxx.chameleon.service.EntityLocalServiceUtil");
DummyLocalServiceUtil= com.liferay.portal.kernel.bean.PortletBeanLocatorUtil.locate("my-services-api", "com.xxxx.chameleon.service.EntityLocalServiceUtil");
DummyLocalServiceUtil= com.liferay.portal.kernel.bean.PortletBeanLocatorUtil.locate("my-services-service", "com.xxxx.chameleon.service.EntityLocalServiceUtil");
Please help
ClassResolverUtil.resolveByPortletClassLoader("com.xxxx.chameleon.service.EntityLocalServiceUtil", "my-services")
Where my service builder module structure is as follows
my-services->my-services-api
>my-services-service
When i try the below suggested method i am getting bean locator exception --> com.liferay.portal.kernel.bean.BeanLocatorException: BeanLocator is not set for servlet context my-services. The below code doesn't even work in the portlet
DummyLocalServiceUtil= com.liferay.portal.kernel.bean.PortletBeanLocatorUtil.locate("my-services", "com.xxxx.chameleon.service.EntityLocalServiceUtil");
DummyLocalServiceUtil= com.liferay.portal.kernel.bean.PortletBeanLocatorUtil.locate("my-services-api", "com.xxxx.chameleon.service.EntityLocalServiceUtil");
DummyLocalServiceUtil= com.liferay.portal.kernel.bean.PortletBeanLocatorUtil.locate("my-services-service", "com.xxxx.chameleon.service.EntityLocalServiceUtil");
Please help
Luiz Henrique Salazar, modifié il y a 4 années.
RE: How to access portal specific -LocalServiceUtil methods in groovy scri
New Member Publications: 10 Date d'inscription: 17/12/19 Publications récentes
Any suggestion in how this can be achieved? I tryed the both solutions you guys suggested but none I could succeed Thanks in advance
Amos Fong, modifié il y a 4 années.
RE: How to access portal specific -LocalServiceUtil methods in groovy scri
Liferay Legend Publications: 2047 Date d'inscription: 07/10/08 Publications récentes
If using 7.0 and later, you should be able to do this for osgi services:
import com.liferay.registry.RegistryUtil
import java.util.Collections;
def registry = RegistryUtil.getRegistry()
def bundleContext = registry._bundleContext
serviceReference = bundleContext.getServiceReference("com.liferay.custom.service.DummyLocalService");
service = bundleContext.getService(serviceReference);
service.dummyMethod();