RE: Liferay 7.1 CE GA4: Permissions in Primefaces Portlet

Marcus Hiebenga, modified 6 Years ago. New Member Posts: 20 Join Date: 1/11/17 Recent Posts
Hello,

I have big problems to get Liferay permissions running in my Primefaces portlet. I have generated a new portlet with this call:

# Liferay Portal 7.1 + JSF 2.2 + PrimeFaces
mvn archetype:generate \
  -DarchetypeGroupId=com.liferay.faces.archetype \
  -DarchetypeArtifactId=com.liferay.faces.archetype.primefaces.portlet \
  -DarchetypeVersion=5.0.6 \
  -DgroupId=com.mycompany \
  -DartifactId=com.mycompany.my.primefaces.portlet
and extended the build.gradle:

apply plugin: 'war'

repositories {
     mavenCentral()
}

dependencies {
    providedCompile group: 'javax.faces', name: 'javax.faces-api', version: '2.2'
    providedCompile group: 'com.liferay.portal', name: 'com.liferay.portal.kernel', version: '3.0.0'
    providedCompile group: 'javax.portlet', name: 'portlet-api', version: '3.0.0'
    providedCompile group: 'org.osgi', name: 'org.osgi.service.component.annotations', version: '1.3.0'
    providedCompile group: 'org.osgi', name: 'org.osgi.core', version: '6.0.0'
            
    runtime group: 'org.glassfish', name: 'javax.faces', version: '2.2.19'
    runtime group: 'com.liferay.faces', name: 'com.liferay.faces.bridge.ext', version: '5.0.4'
    runtime group: 'com.liferay.faces', name: 'com.liferay.faces.bridge.impl', version: '4.1.3'
    
    compile group: 'log4j', name: 'log4j', version: '1.2.14'
    compile group: 'org.primefaces', name: 'primefaces', version: '7.0'
    
}

I tried to get it working with this tutorial:

https://portal.liferay.dev/docs/7-1/tutorials/-/knowledge_base/t/defining-application-permissions

and this example:

https://github.com/liferay/liferay-docs/tree/7.1.x/develop/tutorials/code/com-liferay-docs-guestbook

But I failed.

Everything I tried results in following error:
​​​​​​​
com.liferay.portal.kernel.exception.NoSuchResourceActionException: de.convergys.permissionstest.controller.Controller#ADD_TO_PAGE
        at com.liferay.portal.service.impl.ResourceActionLocalServiceImpl.getResourceAction(ResourceActionLocalServiceImpl.java:313)
        at sun.reflect.GeneratedMethodAccessor223.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:153)
        at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:125)
        at com.sun.proxy.$Proxy33.getResourceAction(Unknown Source)
        at com.liferay.portal.service.impl.ResourcePermissionLocalServiceImpl._updateResourcePermission(ResourcePermissionLocalServiceImpl.java:2112)
        at com.liferay.portal.service.impl.ResourcePermissionLocalServiceImpl.addResourcePermissions(ResourcePermissionLocalServiceImpl.java:375)
        at sun.reflect.GeneratedMethodAccessor224.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:153)
        at com.liferay.portal.spring.transaction.DefaultTransactionExecutor._execute(DefaultTransactionExecutor.java:203)
        at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:94)
        at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:113)
        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:130)
        at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:55)
        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:130)
        at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:55)
        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:130)
        at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:125)
        at com.sun.proxy.$Proxy32.addResourcePermissions(Unknown Source)
        at com.liferay.portal.service.impl.ResourceLocalServiceImpl.addResources(ResourceLocalServiceImpl.java:236)
        at de.convergys.permissionstest.controller.Controller.init(Controller.java:181)
        ...

The goal is to have 3 permissions which I can give to roles. These 3 roles I would like to check with the rendered attribute of the JSF tags.
But I can't get around the error shown above.

I hope you can help me. The complete test portlet is attached.

Best regards
​​​​​​​Marcus 
thumbnail
David H Nebinger, modified 6 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
Question - did you try adding the permission stuff after the initial guestbook deployment?

There is a blurb in the guestbook doco on the permission stuff that if you add it after you previously deployed the service module, this is the kind of error that results.

The published solution is to just whack the database then deploy the service module w/ the permission stuff. This will resolve your missing permissions issue.
Marcus Hiebenga, modified 6 Years ago. New Member Posts: 20 Join Date: 1/11/17 Recent Posts
Hi David,

I tried again with a clean copy of Liferay (empty DB, vanilla Liferay). I can not get it to work.

Do you know of a working JSF Liferay portlet example with permissions available to download?

I think I am doing something wrong in my code but I have no idea where to look at.
 
I hope you can hint me in the right direction.

Best regards
Marcus
thumbnail
David H Nebinger, modified 6 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
I don't think you need to be registering permissions manually in your controller class...

When Liferay is processing the portlet, the portlet.properties will be processed and that has the default.xml mapping for the perms which in turn will pull in your resources.

I'm wondering, though, if the issue is the portlet name...

In default.xml you are registering permissions for de_convergys_permissionstest but your portlet name is de.convergys.permissionstest.

​​​​​​​I think the discrepancy there is preventing Liferay from wiring the two together.
Marcus Hiebenga, modified 6 Years ago. New Member Posts: 20 Join Date: 1/11/17 Recent Posts
Hi David,

I fixed the things you told me in your last post and added the new version as source and war file to this post.

But it doesn't fixes the  "NoSuchResourceActionException: de.convergys.permissionstest#ADD_TO_PAGE".

Here is my test log:

1. Create a clean Liferay 7.1.3 CE GA4 instance (new DB, vanilla installation)
2. Start the instance
3. Deploy the war file of the test application:

02-Aug-2019 10:00:04.050 INFORMATION [main] org.apache.catalina.startup.Catalina.start Server startup in [120.814] milliseconds
2019-08-02 10:01:51.491 INFO  [com.liferay.portal.kernel.deploy.auto.AutoDeployScanner][AutoDeployDir:261] Processing de.convergys.permissionstest.war
2019-08-02 10:01:59.404 INFO  [fileinstall-D:/Java/Servers/7.1-GA4-Test/osgi/war][BaseAutoDeployListener:43] Copying portlets for D:\Java\Servers\7.1-GA4-Test\tomcat-9.0.17\temp\20190802100159376TXOWJUGL\de.convergys.permissionstest.war
2019-08-02 10:01:59.671 INFO  [fileinstall-D:/Java/Servers/7.1-GA4-Test/osgi/war][BaseDeployer:877] Deploying de.convergys.permissionstest.war
2019-08-02 10:02:00.325 INFO  [fileinstall-D:/Java/Servers/7.1-GA4-Test/osgi/war][BaseAutoDeployListener:50] Portlets for D:\Java\Servers\7.1-GA4-Test\tomcat-9.0.17\temp\20190802100159376TXOWJUGL\de.convergys.permissionstest.war copied successfully
10:02:06,141 INFO  [BridgeImpl:194] Initializing Liferay Faces Bridge Implementation 4.1.3 (May 16, 2019 AD) for de.convergys.permissionstest:deconvergyspermissionstest
2019-08-02 10:02:06.173 INFO  [fileinstall-D:/Java/Servers/7.1-GA4-Test/osgi/war][PortletHotDeployListener:305] 1 portlet for de.convergys.permissionstest is available for use
10:02:06,183 INFO  [BridgeSessionListener:83] Context initialized for contextPath=[/o/de.convergys.permissionstest]
2019-08-02 10:02:06.250 INFO  [fileinstall-D:/Java/Servers/7.1-GA4-Test/osgi/war][BundleStartStopLogger:39] STARTED de.convergys.permissionstest_1.0.0 [2024]

4. Check data in the DB of new portlet:

SELECT 
  mvccversion, 
  resourceactionid, 
  name, 
  actionid, 
  bitwisevalue
FROM public.resourceaction
WHERE name LIKE 'de%'
ORDER BY bitwisevalue;

The result:
"0"    "2814"    "deconvergyspermissionstest_WAR_deconvergyspermissionstest"    "VIEW"                       "1"
"0"    "2807"    "deconvergyspermissionstest_WAR_deconvergyspermissionstest"    "PERMISSIONS"                "2"
"0"    "2808"    "deconvergyspermissionstest_WAR_deconvergyspermissionstest"    "TEST_ADMIN_ACCESS"          "4"
"0"    "2809"    "deconvergyspermissionstest_WAR_deconvergyspermissionstest"    "TEST_USER_ACCESS"           "8"
"0"    "2810"    "deconvergyspermissionstest_WAR_deconvergyspermissionstest"    "PREFERENCES"                "16"
"0"    "2811"    "deconvergyspermissionstest_WAR_deconvergyspermissionstest"    "CONFIGURATION"              "32"
"0"    "2812"    "deconvergyspermissionstest_WAR_deconvergyspermissionstest"    "ACCESS_IN_CONTROL_PANEL"    "64"
"0"    "2813"    "deconvergyspermissionstest_WAR_deconvergyspermissionstest"    "TEST_OBSERVER_ACCESS"       "128"
"0"    "2815"    "deconvergyspermissionstest_WAR_deconvergyspermissionstest"    "ADD_TO_PAGE"                "256"

SELECT 
  mvccversion, 
  resourcepermissionid, 
  companyid, 
  name, 
  scope, 
  primkey, 
  primkeyid, 
  roleid, 
  ownerid, 
  actionids, 
  viewactionid
FROM public.resourcepermission
WHERE name LIKE 'de%';
​​​​​​​
"0"    "1350"    "20099"    "deconvergyspermissionstest_WAR_deconvergyspermissionstest"    4    "deconvergyspermissionstest_WAR_deconvergyspermissionstest"    "0"    "20107"    "0"    "511"    true
"0"    "1351"    "20099"    "deconvergyspermissionstest_WAR_deconvergyspermissionstest"    4    "deconvergyspermissionstest_WAR_deconvergyspermissionstest"    "0"    "20114"    "0"    "8"    false
"0"    "1352"    "20099"    "deconvergyspermissionstest_WAR_deconvergyspermissionstest"    1    "20099"    "20099"    "20105"    "0"    "256"    false
"0"    "1353"    "20099"    "deconvergyspermissionstest_WAR_deconvergyspermissionstest"    1    "20099"    "20099"    "20106"    "0"    "256"    false
"0"    "1354"    "20099"    "deconvergyspermissionstest_WAR_deconvergyspermissionstest"    1    "20099"    "20099"    "20108"    "0"    "256"    false
"0"    "1355"    "20099"    "deconvergyspermissionstest_WAR_deconvergyspermissionstest"    1    "20099"    "20099"    "20109"    "0"    "256"    false
​​​​​​​
5. Login as Test User and add portlet to the main page (without page reload). Following is logged:
2019-08-02 10:02:06.173 INFO  [fileinstall-D:/Java/Servers/7.1-GA4-Test/osgi/war][PortletHotDeployListener:305] 1 portlet for de.convergys.permissionstest is available for use
10:02:06,183 INFO  [BridgeSessionListener:83] Context initialized for contextPath=[/o/de.convergys.permissionstest]
2019-08-02 10:02:06.250 INFO  [fileinstall-D:/Java/Servers/7.1-GA4-Test/osgi/war][BundleStartStopLogger:39] STARTED de.convergys.permissionstest_1.0.0 [2024]
10:08:05,837 DEBUG [DebugPhaseListener:66] BEFORE phaseId=[RESTORE_VIEW 1] viewId=[null]
10:08:05,855 DEBUG [DebugPhaseListener:50] AFTER phaseId=[RESTORE_VIEW 1] viewId=[/WEB-INF/views/view.xhtml]
10:08:05,857 DEBUG [DebugPhaseListener:66] BEFORE phaseId=[RENDER_RESPONSE 6] viewId=[/WEB-INF/views/view.xhtml]
2019-08-02 10:08:05.967 ERROR [http-nio-8080-exec-1][Controller:184]
com.liferay.portal.kernel.exception.NoSuchResourceActionException: de.convergys.permissionstest#ADD_TO_PAGE
        at com.liferay.portal.service.impl.ResourceActionLocalServiceImpl.getResourceAction(ResourceActionLocalServiceImpl.java:313)
        at sun.reflect.GeneratedMethodAccessor223.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:153)
        at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:125)
        at com.sun.proxy.$Proxy34.getResourceAction(Unknown Source)
        at com.liferay.portal.service.impl.ResourcePermissionLocalServiceImpl._updateResourcePermission(ResourcePermissionLocalServiceImpl.java:2112)
        at com.liferay.portal.service.impl.ResourcePermissionLocalServiceImpl.addResourcePermissions(ResourcePermissionLocalServiceImpl.java:375)
        at sun.reflect.GeneratedMethodAccessor224.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:153)
        at com.liferay.portal.spring.transaction.DefaultTransactionExecutor._execute(DefaultTransactionExecutor.java:203)
        at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:94)
        at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:113)
        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:130)
        at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:55)
        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:130)
        at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:55)
        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:130)
        at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:125)
        at com.sun.proxy.$Proxy33.addResourcePermissions(Unknown Source)
        at com.liferay.portal.service.impl.ResourceLocalServiceImpl.addResources(ResourceLocalServiceImpl.java:236)
        at de.convergys.permissionstest.controller.Controller.init(Controller.java:182)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.sun.faces.vendor.WebContainerInjectionProvider.invokeAnnotatedMethod(WebContainerInjectionProvider.java:113)
        at com.sun.faces.vendor.WebContainerInjectionProvider.invokePostConstruct(WebContainerInjectionProvider.java:95)
        at com.sun.faces.mgbean.BeanBuilder.invokePostConstruct(BeanBuilder.java:221)
        at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:103)
        at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409)
        at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269)
        at com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:257)
        at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:117)
        at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
        at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
        at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:116)
        at com.sun.el.parser.AstValue.getBase(AstValue.java:150)
        at com.sun.el.parser.AstValue.getValue(AstValue.java:199)
        at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226)
        at com.sun.faces.facelets.el.ELText$ELTextVariable.toString(ELText.java:228)
        at com.sun.faces.facelets.compiler.AttributeInstruction.write(AttributeInstruction.java:89)
        at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
        at com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:183)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
        at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:456)
        at javax.faces.view.ViewDeclarationLanguageWrapper.renderView(ViewDeclarationLanguageWrapper.java:146)
        at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134)
        at com.liferay.faces.bridge.application.internal.ViewHandlerCompatImpl.renderView(ViewHandlerCompatImpl.java:93)
        at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
        at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
        at com.liferay.faces.bridge.internal.BridgePhaseHeaderRenderCommon.executeRender(BridgePhaseHeaderRenderCommon.java:253)
        at com.liferay.faces.bridge.internal.BridgePhaseRenderCompatImpl.execute(BridgePhaseRenderCompatImpl.java:57)
        at com.liferay.faces.bridge.internal.BridgePhaseRenderImpl.execute(BridgePhaseRenderImpl.java:57)
        at com.liferay.faces.bridge.internal.BridgeImpl.doFacesRequest(BridgeImpl.java:157)
        at javax.portlet.faces.GenericFacesPortlet.doView(GenericFacesPortlet.java:753)
        at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:397)
        at javax.portlet.faces.GenericFacesPortlet.doDispatch(GenericFacesPortlet.java:669)
        at javax.portlet.GenericPortlet.render(GenericPortlet.java:291)
        at com.liferay.portlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:127)
        at com.liferay.portlet.ScriptDataPortletFilter.doFilter(ScriptDataPortletFilter.java:58)
        at com.liferay.portlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:124)
        at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:71)
        at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:108)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
        at com.liferay.portal.osgi.web.wab.extender.internal.adapter.AsyncAttributeAdapterServlet.service(AsyncAttributeAdapterServlet.java:85)
        at com.liferay.portal.osgi.web.wab.extender.internal.adapter.ServletExceptionAdapter.service(ServletExceptionAdapter.java:76)
        at org.eclipse.equinox.http.servlet.internal.registration.EndpointRegistration.service(EndpointRegistration.java:153)
        at org.eclipse.equinox.http.servlet.internal.servlet.FilterChainImpl.doFilter(FilterChainImpl.java:50)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:119)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:101)
        at com.liferay.portal.osgi.web.wab.extender.internal.adapter.FilterExceptionAdapter.doFilter(FilterExceptionAdapter.java:46)
        at org.eclipse.equinox.http.servlet.internal.registration.FilterRegistration.doFilter(FilterRegistration.java:121)
        at org.eclipse.equinox.http.servlet.internal.servlet.FilterChainImpl.doFilter(FilterChainImpl.java:45)
        at org.eclipse.equinox.http.servlet.internal.servlet.ResponseStateHandler.processRequest(ResponseStateHandler.java:70)
        at org.eclipse.equinox.http.servlet.internal.context.DispatchTargets.doDispatch(DispatchTargets.java:120)
        at org.eclipse.equinox.http.servlet.internal.servlet.RequestDispatcherAdaptor.include(RequestDispatcherAdaptor.java:48)
        at com.liferay.portlet.internal.InvokerPortletImpl.invoke(InvokerPortletImpl.java:569)
        at com.liferay.portlet.internal.InvokerPortletImpl.invokeRender(InvokerPortletImpl.java:665)
        at com.liferay.portlet.internal.InvokerPortletImpl.render(InvokerPortletImpl.java:362)
        at com.liferay.portal.monitoring.internal.portlet.MonitoringInvokerPortlet.lambda$render$0(MonitoringInvokerPortlet.java:280)
        at com.liferay.portal.monitoring.internal.portlet.MonitoringInvokerPortlet._render(MonitoringInvokerPortlet.java:383)
        at com.liferay.portal.monitoring.internal.portlet.MonitoringInvokerPortlet.render(MonitoringInvokerPortlet.java:278)
        at org.apache.jsp.html.portal.render_005fportlet_jsp._jspService(Unknown Source)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
        at com.liferay.portal.servlet.DirectRequestDispatcher.include(DirectRequestDispatcher.java:64)
        at com.liferay.portal.servlet.DirectRequestDispatcherFactoryImpl$IndirectRequestDispatcher.include(DirectRequestDispatcherFactoryImpl.java:202)
        at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.doDispatch(ClassLoaderRequestDispatcherWrapper.java:79)
        at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.include(ClassLoaderRequestDispatcherWrapper.java:53)
        at com.liferay.portal.servlet.TransferHeadersHelperImpl$TransferHeadersRequestDispatcher.include(TransferHeadersHelperImpl.java:162)
        at com.liferay.portlet.internal.PortletContainerImpl._render(PortletContainerImpl.java:871)
        at com.liferay.portlet.internal.PortletContainerImpl.lambda$render$2(PortletContainerImpl.java:216)
        at com.liferay.portlet.internal.PortletContainerImpl._preserveGroupIds(PortletContainerImpl.java:396)
        at com.liferay.portlet.internal.PortletContainerImpl.render(PortletContainerImpl.java:205)
        at com.liferay.portlet.SecurityPortletContainerWrapper.render(SecurityPortletContainerWrapper.java:142)
        at com.liferay.portlet.RestrictPortletContainerWrapper.lambda$render$0(RestrictPortletContainerWrapper.java:126)
        at com.liferay.portlet.RestrictPortletContainerWrapper._render(RestrictPortletContainerWrapper.java:183)
        at com.liferay.portlet.RestrictPortletContainerWrapper.render(RestrictPortletContainerWrapper.java:124)
        at com.liferay.portal.kernel.portlet.PortletContainerUtil.render(PortletContainerUtil.java:212)
        at com.liferay.portal.action.RenderPortletAction.execute(RenderPortletAction.java:117)
        at com.liferay.portal.action.UpdateLayoutAction.addPortlet(UpdateLayoutAction.java:317)
        at com.liferay.portal.action.UpdateLayoutAction.getJSON(UpdateLayoutAction.java:268)
        at com.liferay.portal.struts.JSONAction.execute(JSONAction.java:77)
        at com.liferay.portal.struts.PortalRequestProcessor._processActionPerform(PortalRequestProcessor.java:715)
        at com.liferay.portal.struts.PortalRequestProcessor._process(PortalRequestProcessor.java:655)
        at com.liferay.portal.struts.PortalRequestProcessor.process(PortalRequestProcessor.java:194)
        at com.liferay.portal.servlet.MainServlet.process(MainServlet.java:1066)
        at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
        at com.liferay.portal.servlet.MainServlet.callParentService(MainServlet.java:597)
        at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:574)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:119)
        at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
        at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:103)
        at com.liferay.portal.apio.internal.architect.servlet.filter.APIDocumentationFilter.processFilter(APIDocumentationFilter.java:74)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
        at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
        at com.liferay.portal.servlet.filters.strip.StripFilter.processFilter(StripFilter.java:341)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
        at com.liferay.portal.servlet.filters.password.modified.PasswordModifiedFilter.processFilter(PasswordModifiedFilter.java:58)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
        at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
        at com.liferay.portal.servlet.filters.secure.BaseAuthFilter.processFilter(BaseAuthFilter.java:340)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
        at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
        at com.liferay.portal.sharepoint.SharepointFilter.processFilter(SharepointFilter.java:88)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
        at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
        at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.processFilter(VirtualHostFilter.java:263)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
        at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
        at com.liferay.portal.monitoring.internal.servlet.filter.MonitoringFilter.processFilter(MonitoringFilter.java:178)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
        at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
        at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
        at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
        at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:389)
        at com.liferay.portal.servlet.filters.urlrewrite.UrlRewriteFilter.processFilter(UrlRewriteFilter.java:65)
        at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:168)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:168)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:101)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:748)
2019-08-02 10:08:05.997 ERROR [http-nio-8080-exec-1][Permission:23] portletResourcePermission is null
2019-08-02 10:08:06.012 ERROR [http-nio-8080-exec-1][Permission:23] portletResourcePermission is null
2019-08-02 10:08:06.013 ERROR [http-nio-8080-exec-1][Permission:23] portletResourcePermission is null
10:08:06,015 DEBUG [DebugPhaseListener:50] AFTER phaseId=[RENDER_RESPONSE 6] viewId=[/WEB-INF/views/view.xhtml]

After page reload the page is rendered but I get the same error in the log. The permissions are available in the permissions page (see Permissionspage.png).

I need a little more help.

Best regards 
​​​​​​​Marcus
thumbnail
David H Nebinger, modified 6 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
So this actually demonstrates that your error, NoSuchResourceActionException: de.convergys.permissionstest#ADD_TO_PAGE, is absolutely true.

Because your portlet name is not "de.convergys.permissionstest", it is "deconvergyspermissionstest_WAR_deconvergyspermissionstest".

I should have keyed in on the war deployment with my last post, sorry about that...

Normally Liferay hides all of the name-style checks. When you check to see if a user has a permission on a resource or model, you don't necessarily need to know how the actual name is going to be determined.

In your case though you're directly invoking the resource local service to add resources manually to your named portlet instance, but you've given the wrong name.

I think if you change your RESOURCE_NAME constant to "deconvergyspermissionstest_WAR_deconvergyspermissionstest" you'll find it magically starts working.

I traced through the resource local service and found that, even though you're passing an 'invalid' name, it is able to find default guest and group permissions for something, so therefore it doesn't really say "Hey I can't find that portlet" even though that's exactly what is going on.

Hope this helps!

Oh, and don't pay attention to Gunnar's response. If he doesn't get that his manual role name checks are against best practices, unlikely to resolve role assignments to groups/orgs/parents/etc., and won't perform as well as the heavily tried and tested Liferay Permission Checking utilities, there's nothing I can do for him. But I can advise you not to go down that road which, although it might work, is an old donkey cart path full of potholes, puddles, etc.
Gunnar Brinkmann, modified 6 Years ago. Junior Member Posts: 54 Join Date: 12/2/11 Recent Posts
Hi,

not an answer to your concrete question, just some details how we deal with permissions (primefaces portlets too):

1st:
We're not using permissions to view portlets.

We're using access restricted sites and private pages and bind page access (page access, not portlet access) to ldap- oder active directory groups.

2nd:
When we need restrictions inside portlets, for example to enable data editing features, then we're defining specific regular Liferay roles, for example "CUSTOMER_EDITOR". These roles are "just strings" we can use in java code like in

<p:commandbutton rendered="#{bean.customerEditor}" ... public boolean iscustomereditor() {     return rolelocalserviceutil.hasuserrole(userid, companyname, "customer_editor", true); }< code></p:commandbutton>
<br><br>userId can be fetched like in<br><br><pre><code>if (liferayPortletHelper.getThemeDisplay().isSignedIn()) { &nbsp;&nbsp;&nbsp; return liferayPortletHelper.getUserId(); }</code></pre><br><br>companyId can be fetched like with <pre><code>PortalUtil.getCompanyId</code></pre><br><br>This way portlets can be used public to view data (no edit roles = no edit features) and access restriced to edit data - for example.<br><br>Regards,<br>gun
Marcus Hiebenga, modified 6 Years ago. New Member Posts: 20 Join Date: 1/11/17 Recent Posts
Hi Gunnar,

thanx for your answer. We already use roles as access rights in other portlets.

But we would prefer our JSF portlets to behave like all other Liferay portlets in regards of permissions and access rights.

So I hope David can help us to solve our problems once and for all.

Best regards
​​​​​​​Marcus
Marcus Hiebenga, modified 6 Years ago. New Member Posts: 20 Join Date: 1/11/17 Recent Posts
Hi David,

the "NoSuchResourceActionException: de.convergys.permissionstest#ADD_TO_PAGE" is gone. Thank you.

When I call this access right check in Controller class:

Permission.contains(getPermissionChecker(), getLoggedInUser().getGroupId(), Constants.ACTION_KEY_ADMIN_ACCESS);

I get a NullPointerException because _portletResourcePermission from Permission class is null. I think the OSGI registration process doesn't work in this context or I have missed something again. Am I right?

Do you have an idea how I can fix the permission registration process?

Best regards
Marcus

P.S. I have attached the latest version of the source code
thumbnail
David H Nebinger, modified 6 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
Do you have a stack trace on the NPE?

I'm not sure that OSGi registration is in play here, the permission registration process should have completed before your code is executing. Getting the stack trace should help identify where the failure might be...
Marcus Hiebenga, modified 6 Years ago. New Member Posts: 20 Join Date: 1/11/17 Recent Posts
Hi David,

​​​​​​​the NPE is thrown on the JSF page. Here is the stack trace:
​​​​​​​
java.lang.NullPointerException
at de.convergys.permissionstest.web.internal.security.permission.resource.Permission.contains(Permission.java:25)
at de.convergys.permissionstest.controller.Controller.isCheckPermissionUser(Controller.java:237)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:321)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at com.sun.el.parser.AstValue.getValue(AstValue.java:139)
at com.sun.el.parser.AstValue.getValue(AstValue.java:203)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:458)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1850)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:456)
at javax.faces.view.ViewDeclarationLanguageWrapper.renderView(ViewDeclarationLanguageWrapper.java:146)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134)
at com.liferay.faces.bridge.application.internal.ViewHandlerCompatImpl.renderView(ViewHandlerCompatImpl.java:93)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at com.liferay.faces.bridge.internal.BridgePhaseHeaderRenderCommon.executeRender(BridgePhaseHeaderRenderCommon.java:253)
at com.liferay.faces.bridge.internal.BridgePhaseRenderCompatImpl.execute(BridgePhaseRenderCompatImpl.java:57)
at com.liferay.faces.bridge.internal.BridgePhaseRenderImpl.execute(BridgePhaseRenderImpl.java:57)
at com.liferay.faces.bridge.internal.BridgeImpl.doFacesRequest(BridgeImpl.java:157)
at javax.portlet.faces.GenericFacesPortlet.doView(GenericFacesPortlet.java:753)
at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:397)
at javax.portlet.faces.GenericFacesPortlet.doDispatch(GenericFacesPortlet.java:669)
at javax.portlet.GenericPortlet.render(GenericPortlet.java:291)
at com.liferay.portlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:127)
at com.liferay.portlet.ScriptDataPortletFilter.doFilter(ScriptDataPortletFilter.java:58)
at com.liferay.portlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:124)
at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:71)
at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:108)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at com.liferay.portal.osgi.web.wab.extender.internal.adapter.AsyncAttributeAdapterServlet.service(AsyncAttributeAdapterServlet.java:85)
at com.liferay.portal.osgi.web.wab.extender.internal.adapter.ServletExceptionAdapter.service(ServletExceptionAdapter.java:76)
at org.eclipse.equinox.http.servlet.internal.registration.EndpointRegistration.service(EndpointRegistration.java:153)
at org.eclipse.equinox.http.servlet.internal.servlet.FilterChainImpl.doFilter(FilterChainImpl.java:50)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:119)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:101)
at com.liferay.portal.osgi.web.wab.extender.internal.adapter.FilterExceptionAdapter.doFilter(FilterExceptionAdapter.java:46)
at org.eclipse.equinox.http.servlet.internal.registration.FilterRegistration.doFilter(FilterRegistration.java:121)
at org.eclipse.equinox.http.servlet.internal.servlet.FilterChainImpl.doFilter(FilterChainImpl.java:45)
at org.eclipse.equinox.http.servlet.internal.servlet.ResponseStateHandler.processRequest(ResponseStateHandler.java:70)
at org.eclipse.equinox.http.servlet.internal.context.DispatchTargets.doDispatch(DispatchTargets.java:120)
at org.eclipse.equinox.http.servlet.internal.servlet.RequestDispatcherAdaptor.include(RequestDispatcherAdaptor.java:48)
at com.liferay.portlet.internal.InvokerPortletImpl.invoke(InvokerPortletImpl.java:569)
at com.liferay.portlet.internal.InvokerPortletImpl.invokeRender(InvokerPortletImpl.java:665)
at com.liferay.portlet.internal.InvokerPortletImpl.render(InvokerPortletImpl.java:362)
at com.liferay.portal.monitoring.internal.portlet.MonitoringInvokerPortlet.lambda$render$0(MonitoringInvokerPortlet.java:280)
at com.liferay.portal.monitoring.internal.portlet.MonitoringInvokerPortlet._render(MonitoringInvokerPortlet.java:383)
at com.liferay.portal.monitoring.internal.portlet.MonitoringInvokerPortlet.render(MonitoringInvokerPortlet.java:278)
at org.apache.jsp.html.portal.render_005fportlet_jsp._jspService(Unknown Source)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at com.liferay.portal.servlet.DirectRequestDispatcher.include(DirectRequestDispatcher.java:64)
at com.liferay.portal.servlet.DirectRequestDispatcherFactoryImpl$IndirectRequestDispatcher.include(DirectRequestDispatcherFactoryImpl.java:202)
at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.doDispatch(ClassLoaderRequestDispatcherWrapper.java:79)
at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.include(ClassLoaderRequestDispatcherWrapper.java:53)
at com.liferay.portal.servlet.TransferHeadersHelperImpl$TransferHeadersRequestDispatcher.include(TransferHeadersHelperImpl.java:162)
at com.liferay.portlet.internal.PortletContainerImpl._render(PortletContainerImpl.java:871)
at com.liferay.portlet.internal.PortletContainerImpl.lambda$render$2(PortletContainerImpl.java:216)
at com.liferay.portlet.internal.PortletContainerImpl._preserveGroupIds(PortletContainerImpl.java:396)
at com.liferay.portlet.internal.PortletContainerImpl.render(PortletContainerImpl.java:205)
at com.liferay.portlet.SecurityPortletContainerWrapper.render(SecurityPortletContainerWrapper.java:142)
at com.liferay.portlet.RestrictPortletContainerWrapper.lambda$render$0(RestrictPortletContainerWrapper.java:126)
at com.liferay.portlet.RestrictPortletContainerWrapper._render(RestrictPortletContainerWrapper.java:183)
at com.liferay.portlet.RestrictPortletContainerWrapper.render(RestrictPortletContainerWrapper.java:124)
at com.liferay.portal.kernel.portlet.PortletContainerUtil.render(PortletContainerUtil.java:212)
at com.liferay.portal.layoutconfiguration.util.PortletRenderer._render(PortletRenderer.java:192)
at com.liferay.portal.layoutconfiguration.util.PortletRenderer.render(PortletRenderer.java:84)
at com.liferay.portal.layoutconfiguration.util.RuntimePageImpl.doProcessTemplate(RuntimePageImpl.java:567)
at com.liferay.portal.layoutconfiguration.util.RuntimePageImpl.doDispatch(RuntimePageImpl.java:340)
at com.liferay.portal.layoutconfiguration.util.RuntimePageImpl.processTemplate(RuntimePageImpl.java:154)
at com.liferay.portal.layoutconfiguration.util.RuntimePageImpl.processTemplate(RuntimePageImpl.java:175)
at com.liferay.portal.kernel.layoutconfiguration.util.RuntimePageUtil.processTemplate(RuntimePageUtil.java:94)
at org.apache.jsp.html.portal.layout.view.portlet_jsp._jspService(Unknown Source)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:476)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:119)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:101)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:712)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:580)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:516)
at com.liferay.portal.servlet.DirectServletPathRegisterDispatcher.include(DirectServletPathRegisterDispatcher.java:67)
at com.liferay.portal.servlet.DirectRequestDispatcherFactoryImpl$IndirectRequestDispatcher.include(DirectRequestDispatcherFactoryImpl.java:202)
at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.doDispatch(ClassLoaderRequestDispatcherWrapper.java:79)
at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.include(ClassLoaderRequestDispatcherWrapper.java:53)
at com.liferay.portal.servlet.TransferHeadersHelperImpl$TransferHeadersRequestDispatcher.include(TransferHeadersHelperImpl.java:162)
at com.liferay.portal.model.impl.LayoutTypeControllerImpl.includeLayoutContent(LayoutTypeControllerImpl.java:171)
at com.liferay.portal.model.impl.LayoutImpl.includeLayoutContent(LayoutImpl.java:903)
at com.liferay.portal.action.LayoutAction.processLayout(LayoutAction.java:404)
at com.liferay.portal.action.LayoutAction.execute(LayoutAction.java:174)
at com.liferay.portal.struts.PortalRequestProcessor._processActionPerform(PortalRequestProcessor.java:715)
at com.liferay.portal.struts.PortalRequestProcessor._process(PortalRequestProcessor.java:655)
at com.liferay.portal.struts.PortalRequestProcessor.process(PortalRequestProcessor.java:194)
at com.liferay.portal.servlet.MainServlet.process(MainServlet.java:1066)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
at com.liferay.portal.servlet.MainServlet.callParentService(MainServlet.java:597)
at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:574)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:119)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:103)
at com.liferay.portal.apio.internal.architect.servlet.filter.APIDocumentationFilter.processFilter(APIDocumentationFilter.java:74)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
at com.liferay.portal.servlet.filters.password.modified.PasswordModifiedFilter.processFilter(PasswordModifiedFilter.java:58)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
at com.liferay.portal.servlet.filters.secure.BaseAuthFilter.processFilter(BaseAuthFilter.java:340)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
at com.liferay.portal.monitoring.internal.servlet.filter.MonitoringFilter.processFilter(MonitoringFilter.java:178)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:101)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:712)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:459)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:384)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
at com.liferay.friendly.url.internal.servlet.FriendlyURLServlet.service(FriendlyURLServlet.java:393)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at com.liferay.portal.servlet.ServletAdapter.service(ServletAdapter.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:119)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:103)
at com.liferay.portal.apio.internal.architect.servlet.filter.APIDocumentationFilter.processFilter(APIDocumentationFilter.java:74)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
at com.liferay.portal.servlet.filters.strip.StripFilter.processFilter(StripFilter.java:341)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
at com.liferay.portal.servlet.filters.i18n.I18nFilter.processFilter(I18nFilter.java:360)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
at com.liferay.portal.servlet.filters.password.modified.PasswordModifiedFilter.processFilter(PasswordModifiedFilter.java:58)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
at com.liferay.portal.servlet.filters.secure.BaseAuthFilter.processFilter(BaseAuthFilter.java:340)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
at com.liferay.portal.servlet.filters.etag.ETagFilter.processFilter(ETagFilter.java:88)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
at com.liferay.portal.servlet.filters.autologin.AutoLoginFilter.processFilter(AutoLoginFilter.java:260)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:144)
at com.liferay.portal.monitoring.internal.servlet.filter.MonitoringFilter.processFilter(MonitoringFilter.java:178)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:101)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:712)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:459)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:384)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.processFilter(VirtualHostFilter.java:372)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:389)
at com.liferay.portal.servlet.filters.urlrewrite.UrlRewriteFilter.processFilter(UrlRewriteFilter.java:65)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:168)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:168)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:101)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Marcus Hiebenga, modified 6 Years ago. New Member Posts: 20 Join Date: 1/11/17 Recent Posts
Hi David,

I have changed the static access to JSF managed bean injection and replaced the resource.name of Permission and PortletResourcePermissionRegistrar class to the packagename 'de.convergys.permissionstest' like it is done in guestbook example.

In Permission class I now have a mix of JSF and OSGI annotations. Is that correct?

I made the call 'blade sh scr:list > scrList.txt' and added the result here. My package 'de.convergys...' is not in the list. Does it mean OSGI did nothing?

At the end nothing has changed since my last try. It is the same NPE.

I know you are very busy with the forum but could you or a colleague of you please get this little example fixed. At the moment I think I haven't the insight into liferays OSGI/Annotation magic to get it done by myself.

Best regard
Marcus
thumbnail
David H Nebinger, modified 6 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
So this is a problem when you use static methods; static methods don't care if the OSGi component was registered or not.

This also has nothing to do w/ JSF, per se, it is strictly about whether the given OSGi component has started or not.

Since the _portletResourcePermission is null, that means it wasn't injected in by OSGi so your component didn't start. Likely this points to no matching target component for your filter.

Using scr:list and scr:info on your target component, you should be able to see whether your component is active or not and why it might not have started.

I'd also recommend dropping the use of static methods altogether since they hide whether a component has been started or not. There are better ways to inject instances into your faces context, but relying on static methods can lead you to these kinds of rabbit holes wondering if your components were properly started or not.
Marcus Hiebenga, modified 6 Years ago. New Member Posts: 20 Join Date: 1/11/17 Recent Posts
Hi David,

my reply was posted to the last entry. Spoiler: I can not get it to work.

Thank you for your ongoing help

Best regards
Marcus
thumbnail
Neil Griffin, modified 6 Years ago. Liferay Legend Posts: 2655 Join Date: 7/27/05 Recent Posts
Hi Marcus,
Java EE style WAR-based portlets ultimately get registered as OSGi Web Application Bundles (WABs), which means that they are registered as OSGi modules. However, they do not participate in the OSGi lifecycle in the same way that Declarative Services (DS) portlets do. Because of that, we recommend that you make use of the OSGi ServiceTracker pattern, which is described in the doc page titled Services in JSF.
Kind Regards,
Neil
Marcus Hiebenga, modified 6 Years ago. New Member Posts: 20 Join Date: 1/11/17 Recent Posts
Hi Neil,
thanks for your answer.
I finally got it working. I attached the working example to this post.
But in my solution are two code snippets which are working in my environment but I think could break in other environments.
1. To get the prim key id I use following code:
private String getPrimKeyID() {
    return String.valueOf("20129_LAYOUT_" + Constants.RESOURCE_NAME);
  }

The prefix "20129_LAYOUT_" is created in the database and I used it as a constant. I don't think that is the right thing to do. What is the best solution in the JSF context to get the correct prim key id?

2. I couldn't get the owner permissions to work correctly. 
How can I get the portlet instance owner and check the configured permissions?

Thanks for your help
Best regards
Marcus
thumbnail
Neil Griffin, modified 6 Years ago. Liferay Legend Posts: 2655 Join Date: 7/27/05 Recent Posts
Hi Markus,

I reviewed the project that you attached and I think that I may have identified a general problem of not using the ThemeDisplay API. In your Facelet view you have markup like the following:

<h:outputtext value="Admin Access" rendered="#{controller.checkPermissionAdmin}" />


Since you are trying to determine whether or not the current user has permission to link on a link, and since this is in a Facelet view, that means this is all happening within the scope of a PortletRequest.

So what I recommend you do, is rather than accessing ServiceContextThreadLocal and PermissionThreadLocal in your Controller bean, access the request-scoped ThemeDisplay object, like this:

FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
ThemeDisplay themeDisplay = (ThemeDisplay) externalContext.getRequestParameterMap().get(WebKeys.THEME_DISPLAY);


Then call one of the many many helpful methods on ThemeDisplay in order to get the information you want. For example:


long userId = themeDisplay.getUserId();
PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();


-- Neil