NoSuchGroupException: No Group exists with the primary key 0 when updating a Journal Article via service API
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
learn-legacy-article-disclaimer-text
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