Message Boards

Adding comments issue

Rafał Pyyniak, modified 3 Months ago.

Adding comments issue

New Member Posts: 5 Join Date: 6/26/20 Recent Posts



I'm working on a quite large portal. It has been recently migrated from Liferay 6.2 to Liferay 7.4.1. The migration itself went fine and we managed to make the portal work like it should but we're still struggling with one last issue.

The issue is that we use the "Page comments" portlet on some pages and it seems to be broken. I did some debugging through Liferay code and some sampling of running Liferay instance and I found out that the issue is related to the way Liferay adds comments.

Basically in MBMessageLocalServiceImpl there is a method called "startWorkflowInstance" which calls "getMessageURL" and then it goes to PortalImpl.getLayoutFullURL->PortalImpl.getPlidFromPortletId. The whole stacktrace on the screen below:

In this last method call (getPlidFromPortletId( List<Layout> layouts, String portletId, long scopeGroupId)) there is for loop:

for (Layout layout: layouts) and then another for loop inside for (Portlet portlet : layoutTypePortlet.getAllPortlets()). Also for each layout there is a method call for "getScopeGroupId" and then "_getScopeGroupId" which is quite long itself as it calls for portlet preferences setup

This makes it really long for one of our sites which has more than 5000 layouts and adding message longs really really long time - about 5 minutes.

I tried to increase the ehcache settings:

  • timeToIdleSeconds - to make the cached result stay in cache for longer time
  • maxElementsInMemory - some of the caches were full so I tried to increase that

It worked "a little bit" but it still takes about four minutes. I found out that even though I increased some of the FinderCache it didn't work. Below is example finder cache I tried to increase:


Please note that I increase the EntityCache in the same module-multi-vm.xml and it works for EntityCache but for FinderCache - I found out that it's not created "right away" but only after the finder is first called so I guess there is some specific code that sets the settings directly and I couldn't find a way to override that cache settings.


To sum up. My questions are:

  • Do anyone have any idea how that issue can be fixed? Anyone knows if there are any plans for fixing that in next Liferay version for example? My clien't doesn't have a DXP subscription sadly so I can't contact the support :(
  • What is the idea of this "startWorkflowInstance" method? We don't use workflow so perhaps it's reduntant? Perhaps I can override that method with Service Wrapper somehow and get rid of that part? Won't it break anything? I don't need workflow if it's only for that.
  • Is there any way of increasing that finder cache? I couldn't find any other way of doing that in the docs


Rafał Pydyniak, modified 2 Months ago.

RE: Adding comments issue

New Member Posts: 5 Join Date: 6/26/20 Recent Posts



anyone can help? I did a test on newest version ( and the issue is still here. Steps to reproduce:

  • Start portal from the docker image e.g. docker run -it -p 8080:8080 liferay/portal:
  • Log in
  • Add a lot of pages e.g. using the JS script below (change parentLayoutId! You can use 0 if you don't want the page to be subpage of any other):
    for(let i=0; i<1000; i++) {
        groupId: 20123,
        privateLayout: false,
        parentLayoutId: 14,
        name: 'Layout-test' + i,
        title: 'Layout-test' + i,
        description: '',
        type: 'portlet',
        hidden: true,
        friendlyURL: ''
      function(obj) {
  • I suggest adding at least 5000 pages by using the script above few times (I tried to do that at once but it failed at some point, I think because of resources). You can also verify afterwards that all the pages were created by going to Control Panel -> System settings -> Server administration -> Script and use script:
    number = com.liferay.portal.kernel.service.LayoutLocalServiceUtil.getLayoutsCount();
  • Go to any page and add "Page comments" widget. Add comment and count time. For me it was 2 minutes . In real world scenario it would've been much more because there is a loop on all layouts and all portlets on these layouts - in this simple example the pages are empty.

The 5000 pages is not an imaginary example - I have that in one of my projects