<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>How to access portal specific  -LocalServiceUtil methods in groovy script</title>
  <link rel="self" href="https://uat.liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=27068199" />
  <subtitle>How to access portal specific  -LocalServiceUtil methods in groovy script</subtitle>
  <id>https://uat.liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=27068199</id>
  <updated>2026-10-15T11:16:40Z</updated>
  <dc:date>2026-10-15T11:16:40Z</dc:date>
  <entry>
    <title>RE: How to access portal specific  -LocalServiceUtil methods in groovy scri</title>
    <link rel="alternate" href="https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118705126" />
    <author>
      <name>Amos Fong</name>
    </author>
    <id>https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118705126</id>
    <updated>2020-03-10T15:58:42Z</updated>
    <published>2020-03-10T15:58:42Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;If using 7.0 and later, you should be able to do this for osgi services:&lt;pre&gt;&lt;code&gt;import com.liferay.registry.RegistryUtil
import java.util.Collections;
&lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code&gt;
def registry = RegistryUtil.getRegistry()&lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code&gt;def bundleContext = registry._bundleContext&lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code&gt;serviceReference = bundleContext.getServiceReference("com.liferay.custom.service.DummyLocalService");&lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code&gt;service = bundleContext.getService(serviceReference);&lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code&gt;service.dummyMethod();&lt;/code&gt;&lt;/pre&gt;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Amos Fong</dc:creator>
    <dc:date>2020-03-10T15:58:42Z</dc:date>
  </entry>
  <entry>
    <title>RE: How to access portal specific  -LocalServiceUtil methods in groovy scri</title>
    <link rel="alternate" href="https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118701249" />
    <author>
      <name>Luiz Henrique Salazar</name>
    </author>
    <id>https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118701249</id>
    <updated>2020-03-09T17:11:58Z</updated>
    <published>2020-03-09T17:11:58Z</published>
    <summary type="html">Any suggestion in how this can be achieved? I tryed the both solutions you guys suggested but none I could succeed &lt;img alt="emoticon" src="@theme_images_path@/emoticons/sad.gif" &gt; Thanks in advance</summary>
    <dc:creator>Luiz Henrique Salazar</dc:creator>
    <dc:date>2020-03-09T17:11:58Z</dc:date>
  </entry>
  <entry>
    <title>RE: How to access portal specific  -LocalServiceUtil methods in groovy scri</title>
    <link rel="alternate" href="https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=86018988" />
    <author>
      <name>Mohammad Azharuddin</name>
    </author>
    <id>https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=86018988</id>
    <updated>2017-02-14T14:19:39Z</updated>
    <published>2017-02-14T14:19:39Z</published>
    <summary type="html">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&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;ClassResolverUtil.resolveByPortletClassLoader(&amp;#34;com.xxxx.chameleon.service.EntityLocalServiceUtil&amp;#34;, &amp;#34;my-services&amp;#34;)&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Where my service builder  module structure is as follows&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;my-services-&amp;gt;my-services-api&lt;br /&gt;                        &amp;gt;my-services-service&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;When i try the below suggested method i am getting bean locator exception --&amp;gt; com.liferay.portal.kernel.bean.BeanLocatorException: BeanLocator is not set for servlet context my-services. The below code doesn&amp;#39;t even work in the portlet &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;DummyLocalServiceUtil= com.liferay.portal.kernel.bean.PortletBeanLocatorUtil.locate(&amp;#34;my-services&amp;#34;, &amp;#34;com.xxxx.chameleon.service.EntityLocalServiceUtil&amp;#34;);&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;DummyLocalServiceUtil= com.liferay.portal.kernel.bean.PortletBeanLocatorUtil.locate(&amp;#34;my-services-api&amp;#34;, &amp;#34;com.xxxx.chameleon.service.EntityLocalServiceUtil&amp;#34;);&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;DummyLocalServiceUtil= com.liferay.portal.kernel.bean.PortletBeanLocatorUtil.locate(&amp;#34;my-services-service&amp;#34;, &amp;#34;com.xxxx.chameleon.service.EntityLocalServiceUtil&amp;#34;);&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Please help</summary>
    <dc:creator>Mohammad Azharuddin</dc:creator>
    <dc:date>2017-02-14T14:19:39Z</dc:date>
  </entry>
  <entry>
    <title>RE: How to access portal specific  -LocalServiceUtil methods in groovy scri</title>
    <link rel="alternate" href="https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=86018709" />
    <author>
      <name>Mohammad Azharuddin</name>
    </author>
    <id>https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=86018709</id>
    <updated>2017-02-14T14:10:02Z</updated>
    <published>2017-02-14T14:10:02Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;div class="quote-title"&gt;Amos Fong:&lt;/div&gt;&lt;blockquote&gt;Hey Mohammed,&lt;br&gt;&lt;br&gt;Since making this post, I've learned that you could call portlet services using bean locator:&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;DummyLocalServiceUtil= com.liferay.portal.kernel.bean.PortletBeanLocatorUtil.locate("chameleon-portlet", "com.xxxx.chameleon.service.DummyLocalServiceUtil");

DummyLocalServiceUtil.addDummy();&lt;/code&gt;&lt;/pre&gt;&lt;/blockquote&gt;&lt;br&gt;&lt;br&gt;Hi Amos Fong &lt;br&gt;&lt;br&gt;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 ..?&lt;br&gt;&lt;br&gt;Thanks &lt;br&gt;Azhar&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Mohammad Azharuddin</dc:creator>
    <dc:date>2017-02-14T14:10:02Z</dc:date>
  </entry>
  <entry>
    <title>RE: How to access portal specific  -LocalServiceUtil methods in groovy scri</title>
    <link rel="alternate" href="https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=85898472" />
    <author>
      <name>Amos Fong</name>
    </author>
    <id>https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=85898472</id>
    <updated>2017-02-10T17:35:35Z</updated>
    <published>2017-02-10T17:35:35Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Hey Mohammed,&lt;br&gt;&lt;br&gt;Since making this post, I've learned that you could call portlet services using bean locator:&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;DummyLocalServiceUtil= com.liferay.portal.kernel.bean.PortletBeanLocatorUtil.locate("chameleon-portlet", "com.xxxx.chameleon.service.DummyLocalServiceUtil");

DummyLocalServiceUtil.addDummy();&lt;/code&gt;&lt;/pre&gt;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Amos Fong</dc:creator>
    <dc:date>2017-02-10T17:35:35Z</dc:date>
  </entry>
  <entry>
    <title>RE: How to access portal specific  -LocalServiceUtil methods in groovy scri</title>
    <link rel="alternate" href="https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=85846596" />
    <author>
      <name>Mohammad Azharuddin</name>
    </author>
    <id>https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=85846596</id>
    <updated>2017-02-09T17:18:01Z</updated>
    <published>2017-02-09T17:18:01Z</published>
    <summary type="html">&lt;div class="quote-title"&gt;Amos Fong:&lt;/div&gt;&lt;blockquote&gt;Hi Ashish,&lt;br /&gt;&lt;br /&gt;The problem is the groovy script executed by the portal, which is in the portal&amp;#39;s classloader. Your service is in your plugin and thus not available to the portal. I&amp;#39;m not sure if it&amp;#39;s possible to somehow manipulate the classloader in groovy, but one thing you can do is move your plugin&amp;#39;s service.jar (and remove it from your plugin) to the app server&amp;#39;s global lib.&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Hi All&lt;br /&gt;&lt;br /&gt; can some one help me to manipulate the classloader in groovy. I am on LR7</summary>
    <dc:creator>Mohammad Azharuddin</dc:creator>
    <dc:date>2017-02-09T17:18:01Z</dc:date>
  </entry>
  <entry>
    <title>RE: How to access portal specific  -LocalServiceUtil methods in groovy scri</title>
    <link rel="alternate" href="https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=27101244" />
    <author>
      <name>Amos Fong</name>
    </author>
    <id>https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=27101244</id>
    <updated>2013-08-06T20:57:54Z</updated>
    <published>2013-08-06T20:57:54Z</published>
    <summary type="html">Hi Ashish,&lt;br /&gt;&lt;br /&gt;The problem is the groovy script executed by the portal, which is in the portal&amp;#39;s classloader. Your service is in your plugin and thus not available to the portal. I&amp;#39;m not sure if it&amp;#39;s possible to somehow manipulate the classloader in groovy, but one thing you can do is move your plugin&amp;#39;s service.jar (and remove it from your plugin) to the app server&amp;#39;s global lib.</summary>
    <dc:creator>Amos Fong</dc:creator>
    <dc:date>2013-08-06T20:57:54Z</dc:date>
  </entry>
  <entry>
    <title>How to access portal specific  -LocalServiceUtil methods in groovy script</title>
    <link rel="alternate" href="https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=27068198" />
    <author>
      <name>Ashish Ashok</name>
    </author>
    <id>https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=27068198</id>
    <updated>2013-08-05T20:46:46Z</updated>
    <published>2013-08-05T20:46:46Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;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.&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;
import com.xxxx.chameleon.service.DummyLocalServiceUtil;
DummyLocalServiceUtil.getJournalTemplate(10180,"MOVIETEMPLATE");
&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;So I then tried to go to &lt;br&gt;Control panel -&amp;gt; Server Administration -&amp;gt; script&lt;br&gt;&lt;br&gt;In the script I added the above code. Once I run the script I get the following error&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;
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");
&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;Can anyone please explain me how to work on this issue. Thanks in advance.&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Ashish Ashok</dc:creator>
    <dc:date>2013-08-05T20:46:46Z</dc:date>
  </entry>
</feed>
