PUBLIC - Liferay Portal Community Edition
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-19415

Strange behavior of WorkflowTaskManagerUtil.assignWorkflowTaskToUser method

    Details

    • Similar Issues:
      Show 5 results 

      Description

      Using Liferay 6.0.6 and activiti-web-6.0.6.8.war plugin, I used the below method in a JSP page:

      WorkflowTaskManagerUtil.assignWorkflowTaskToUser(
      companyId,
      userId,
      workflowTasks.get.getWorkflowTaskId(),
      assigneeUserId,
      "Some note ...",
      now,
      workflowContext);

      I'm able to assign a task to the specified assigneeUserId with success.

      BUT if I use the SAME method inside a class that implements MessageListener, I get the below error:

      java.lang.NullPointerException
      at com.liferay.portal.workflow.WorkflowPermissionAdvice.invoke(WorkflowPermissionAdvice.java:40)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)
      at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)
      at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      at $Proxy231.assignWorkflowTaskToUser(Unknown Source)
      at com.liferay.portal.kernel.workflow.WorkflowTaskManagerUtil.assignWorkflowTaskToUser(WorkflowTaskManagerUtil.java:50)
      at o2.base.listener.NewUserDittaListener.assignWFtoGestoreDitta(NewUserDittaListener.java:421)
      at o2.base.listener.NewUserDittaListener.doReceive(NewUserDittaListener.java:111)
      at o2.base.listener.NewUserDittaListener.receive(NewUserDittaListener.java:60)
      at com.liferay.portal.kernel.messaging.InvokerMessageListener.receive(InvokerMessageListener.java:63)
      at com.liferay.portal.kernel.messaging.ParallelDestination$1.run(ParallelDestination.java:61)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)

        Activity

        Hide
        Ivano Carrara added a comment -

        The same issue using Kaleo Workflow engine ...

        Show
        Ivano Carrara added a comment - The same issue using Kaleo Workflow engine ...
        Hide
        Michael Han added a comment -

        It's because you don't have a PermissionChecker active on that thread. Can you be more specific about what you're trying to do?

        Show
        Michael Han added a comment - It's because you don't have a PermissionChecker active on that thread. Can you be more specific about what you're trying to do?
        Hide
        Ivano Carrara added a comment -

        After a user inserted a new asset, based on some consideration the portal have to assign the approve workflow process to a specific UserId.
        I can't modify the workflow definition (XML) because I don't know in advance the UserId to wich assigne the task.

        Actually I'm doing that in the Service Layer but I need to wait almost 3 seconds before to find the just started workflow process... This cause the wait of the UI where the user created the new asset.

        So I prefer to assign the task to the User in a class activated by Message Bus.

        But using the WorkflowTaskManagerUtil.assignWorkflowTaskToUser() method in the Message Bus cause the reported exception...

        Show
        Ivano Carrara added a comment - After a user inserted a new asset, based on some consideration the portal have to assign the approve workflow process to a specific UserId. I can't modify the workflow definition (XML) because I don't know in advance the UserId to wich assigne the task. Actually I'm doing that in the Service Layer but I need to wait almost 3 seconds before to find the just started workflow process... This cause the wait of the UI where the user created the new asset. So I prefer to assign the task to the User in a class activated by Message Bus. But using the WorkflowTaskManagerUtil.assignWorkflowTaskToUser() method in the Message Bus cause the reported exception...
        Hide
        Hitesh Methani added a comment -

        This issue comes probably because, permission checker is set to null
        I was able to have a workaround for the issue by setting permission checker in following way :
        PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.getPermissionCheckerFactory().create(UserLocalServiceUtil.getUser(userId), true);
        PermissionThreadLocal.setPermissionChecker(permissionChecker);

        By adding these lines before executing the method, it worked fine.

        Show
        Hitesh Methani added a comment - This issue comes probably because, permission checker is set to null I was able to have a workaround for the issue by setting permission checker in following way : PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.getPermissionCheckerFactory().create(UserLocalServiceUtil.getUser(userId), true); PermissionThreadLocal.setPermissionChecker(permissionChecker); By adding these lines before executing the method, it worked fine.
        Hide
        Aniceto P Madrid added a comment -

        This is not an issue.
        I suggest to close this issue

        Show
        Aniceto P Madrid added a comment - This is not an issue. I suggest to close this issue

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since last comment:
              2 years, 1 week ago

              Development

                Structure Helper Panel