Nicolas Raoul
Nicolas Raoul

Reputation: 60213

NoSuchGroupException: No Group exists with the key {companyId=20116, friendlyURL=site1}

I manually created a site in Liferay, and want to get its object from a Java Liferay module. If I understand correctly, a site is represented by the Group class. So I wrote this:

Group group = GroupLocalServiceUtil.getFriendlyURLGroup(
                                          Utils.getCompanyId(), "site1");

Problem: I get this exception:

com.liferay.portal.kernel.exception.NoSuchGroupException: No Group exists with the key {companyId=20116, friendlyURL=site1}
    at com.liferay.portal.service.persistence.impl.GroupPersistenceImpl.findByC_F(GroupPersistenceImpl.java:3563)
    at com.liferay.portal.service.impl.GroupLocalServiceImpl.getFriendlyURLGroup(GroupLocalServiceImpl.java:1141)

I am 100% sure that site1 exists. The exception still happens after I reindex all in "Server Administration".

Friendly URL

What am I doing wrong?

Upvotes: 1

Views: 3821

Answers (1)

Devz
Devz

Reputation: 613

Everything is perfect but when you lookup with friendly URL. You should pass friendly URL in param like "/site1"

Group group = GroupLocalServiceUtil.getFriendlyURLGroup(
                                          Utils.getCompanyId(), "/site1");

Upvotes: 2

Related Questions