com.liferay.portal.kernel.messaging.MessageListenerException: java.lang.RuntimeException: com.liferay.portal.security.auth.PrincipalException: PermissionChecker not initialized at com.liferay.portal.kernel.scheduler.messaging.SchedulerEventMessageListenerWrapper.receive(SchedulerEventMessageListenerWrapper.java:86) at com.liferay.portal.kernel.messaging.InvokerMessageListener.receive(InvokerMessageListener.java:72) at com.liferay.portal.kernel.messaging.ParallelDestination$1.run(ParallelDestination.java:71) at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask._runTask(ThreadPoolExecutor.java:682) at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask.run(ThreadPoolExecutor.java:593) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.RuntimeException: com.liferay.portal.security.auth.PrincipalException: PermissionChecker not initialized at com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl.getAttribute(ExpandoBridgeImpl.java:219) at com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl.getAttribute(ExpandoBridgeImpl.java:199) at sun.reflect.GeneratedMethodAccessor6456.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.liferay.portal.kernel.bean.ClassLoaderBeanHandler.invoke(ClassLoaderBeanHandler.java:67) at com.sun.proxy.$Proxy1399.receive(Unknown Source) at com.liferay.portal.kernel.scheduler.messaging.SchedulerEventMessageListenerWrapper.receive(SchedulerEventMessageListenerWrapper.java:77) ... 5 more Caused by: com.liferay.portal.security.auth.PrincipalException: PermissionChecker not initialized at com.liferay.portal.service.BaseServiceImpl.getPermissionChecker(BaseServiceImpl.java:82) at com.liferay.portlet.expando.service.impl.ExpandoValueServiceImpl.getData(ExpandoValueServiceImpl.java:125) at sun.reflect.GeneratedMethodAccessor1874.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:115) at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62) at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:51) at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111) at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56) at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111) at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56) at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111) at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:175) at com.sun.proxy.$Proxy228.getData(Unknown Source) at com.liferay.portlet.expando.service.ExpandoValueServiceUtil.getData(ExpandoValueServiceUtil.java:107) at com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl.getAttribute(ExpandoBridgeImpl.java:208) ... 14 more
Este error se lanzaba a la hora de consultar el valor del campo personalizado desde una tarea programada:
user.getExpandoBridge().getAttribute("nombre-del-campo-personalizado");
La solución a este problema, documentado en los foros de Liferay fue el siguiente:
try{ //Backup del permiso actual PermissionChecker permissionCheckerBackup= PermissionThreadLocal.getPermissionChecker(); //Recupera el valor del del campo personalizado PrincipalThreadLocal.setName(user.getUserId()); PermissionChecker permissionChecker; permissionChecker = PermissionCheckerFactoryUtil.create(user); PermissionThreadLocal.setPermissionChecker(permissionChecker); campoPersonalizado=(boolean) user.getExpandoBridge().getAttribute("nombre-del-campo-personalizado"); //Restablece el permiso inicial PermissionThreadLocal.setPermissionChecker(permissionCheckerBackup); }catch(Exception ex){ ex.printStackTrace(); }
Más información: https://liferay.dev/forums/-/message_boards/message/48763277
No hay comentarios:
Publicar un comentario
Déjanos tu comentario