Legacy Knowledge Base
Published Jun. 30, 2025

NoSuchGroupException: No Group exists with the primary key 0 when updating a Journal Article via service API

Written By

Ricardo Couso

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

Issue

  • When trying to update a Journal Article (i.e., a web content) using the service API 
    journalArticleLocalService.updateArticle(
    journalArticle.getUserId(), journalArticle.getGroupId(),
    journalArticle.getFolderId(), journalArticle.getArticleId(),
    journalArticle.getVersion(), StringEscapeUtils.unescapeXml(content),
    new ServiceContext()
    );
    the following error happens
    com.liferay.portal.kernel.exception.NoSuchGroupException: No Group exists with the primary key 0
    
    even though the relevant group (i.e., the site) seems to be set correctly with journalArticle.getGroupId().
  • Why does this error happen?

Environment

  • Quarterly Release 2024.Q2, 2024.Q1, 2023.Q2, 2023.Q1

Resolution

  • The error occurs because the object ServiceContext doesn't have the information for the groupId.
  • Make sure to establish it with serviceContext.setScopeGroupId(article.getGroupId()).
Did this article resolve your issue ?

Legacy Knowledge Base