Search code examples
springliferayhookportletspring-portlet-mvc

Liferay 7 Role/ Permission issue : You do not have the roles required to access this portlet


I created a PortletMVC in Liferay 7.3.0 it is deployed successfully in Tomcat 9 but when I drag it in the portal, I cannot see it and the message displayed is the following :

" You do not have the roles required to access this portlet.
" 

[Image]

enter image description here

I checked the permission of the page it was public and the guest can view it,

enter image description here

Can anyone please help if there is something wrong thanks. This is the classController:

@Component(
    immediate = true, 
    property = {
            "path=/login/login",
            "javax.portlet.security-role-ref=guest,power-user,user",
    },
    service = StrutsPortletAction.class
)
public class BladePortletAction extends BaseStrutsPortletAction {

    @Override
    public void processAction(
            StrutsPortletAction originalStrutsPortletAction,
            PortletConfig portletConfig, ActionRequest actionRequest,
            ActionResponse actionResponse)
        throws Exception {....}

the console display :

[SecurityPortletContainerWrapper:235] Invalid portlet ID /app_WAR_app

Solution

  • As the error says:

    [SecurityPortletContainerWrapper:235] Invalid portlet ID /app_WAR_app
    

    You didn't attach a unique ID to your portlet yet, you should know that in Liferay, every portlet have a unique ID (KEY) using the property javax.portlet.name

    Take this code as an example:

    @Component(
            immediate = true,
            property = {
                    "javax.portlet.name=com_fr_bladeExamplePortlet"
            },
            properties = "OSGI-INF/portlet.properties",
            service = Portlet.class
    )
    public class SearchPortlet extends MVCPortlet {
    }
    

    If you are using Liferay DXP, I recommend you to work with MVCPortlet, it's simple, light, effective and ease of use.

    Liferay MVC Porlet

    Best regards,