Message Boards

MessageListenerException

thumbnail
ali yeganeh, modified 4 Years ago.

MessageListenerException

Regular Member Posts: 148 Join Date: 5/1/19 Recent Posts
Hi
I create a workflow module and an XML Workflow
Both working correctly in my machine
When I run them on another machine, I get the following exception!!!!

seDestinationName=null, responseId=null, payload=com.liferay.portal.workflow.kaleo.runtime.graph.PathElement@4b8eeb6a,
values={defaultLocale=fa_IR, companyId=20101, groupId=0, principalName=39762, permissionChecker=com.liferay.portal.kernel.util.TransientValue@69bfccd,
 siteDefaultLocale=fa_IR, themeDisplayLocale=fa_IR}}
 
com.liferay.portal.kernel.messaging.MessageListenerException: java.lang.NullPointerException
        at com.liferay.portal.kernel.messaging.BaseMessageListener.receive(BaseMessageListener.java:32)
        at com.liferay.portal.kernel.messaging.InvokerMessageListener.receive(InvokerMessageListener.java:74)
        at com.liferay.portal.messaging.internal.ParallelDestination$1.run(ParallelDestination.java:56)
        at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask._runTask(ThreadPoolExecutor.java:752)
        at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask.run(ThreadPoolExecutor.java:664)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
        at com.liferay.portal.workflow.kaleo.runtime.assignment.BaseTaskAssignmentSelector.getRoleKaleoTaskAssignments(BaseTaskAssignmentSelector.java:70)
        at com.liferay.portal.workflow.kaleo.runtime.assignment.BaseTaskAssignmentSelector.getKaleoTaskAssignments(BaseTaskAssignmentSelector.java:52)
        at com.liferay.portal.workflow.kaleo.runtime.scripting.internal.assignment.ScriptingLanguagesTaskAssignmentSelector.calculateTaskAssignments(ScriptingLanguagesTaskAssignmentSelector.java:64)
        at com.liferay.portal.workflow.kaleo.runtime.internal.assignment.MultiLanguageTaskAssignmentSelector.calculateTaskAssignments(MultiLanguageTaskAssignmentSelector.java:82)
        at com.liferay.portal.workflow.kaleo.runtime.internal.node.TaskNodeExecutor.createTaskInstanceToken(TaskNodeExecutor.java:110)
        at com.liferay.portal.workflow.kaleo.runtime.internal.node.TaskNodeExecutor.doEnter(TaskNodeExecutor.java:139)
        at com.liferay.portal.workflow.kaleo.runtime.node.BaseNodeExecutor.enter(BaseNodeExecutor.java:51)
        at com.liferay.portal.workflow.kaleo.runtime.internal.graph.DefaultGraphWalker.follow(DefaultGraphWalker.java:70)
        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.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:50)
        at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:69)
        at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:57)
        at com.liferay.portal.spring.aop.AopInvocationHandler.invoke(AopInvocationHandler.java:49)
        at com.sun.proxy.$Proxy919.follow(Unknown Source)
        at com.liferay.portal.workflow.kaleo.runtime.internal.graph.messaging.PathElementMessageListener.doReceive(PathElementMessageListener.java:47)
        at com.liferay.portal.kernel.messaging.BaseMessageListener.receive(BaseMessageListener.java:26)
        ... 5 more
thumbnail
David H Nebinger, modified 4 Years ago.

RE: MessageListenerException

Liferay Legend Posts: 14916 Join Date: 9/2/06 Recent Posts
Are the roles the same on both systems?
thumbnail
ali yeganeh, modified 4 Years ago.

RE: MessageListenerException

Regular Member Posts: 148 Join Date: 5/1/19 Recent Posts
Hi dear David

My problem solved,  my role name wasn't the same on both system and when I get role through groovy script, this exception happened.
Why this exception is incomprehensible!!!
thumbnail
David H Nebinger, modified 4 Years ago.

RE: MessageListenerException

Liferay Legend Posts: 14916 Join Date: 9/2/06 Recent Posts
I'm a big fan of defensive programming. When you check my code, any time I retrieve a value from a subroutine I'm always checking it for validity before using it. It's a habit I got into a long time ago and I feel that it has served me well.

That said, I understand that all of that checking happening in a known, consistent and controlled system, invoked for every request even under heavy load, I understand that I am adding unnecessary overhead. That doesn't bother me too much because I tend not to work in code that is invoked under every request, my code isn't scrutinized and profiled to ensure that I'm not wasting time or resources at such a small scale, etc. So I can afford all of my defensive programming tactics.

The portal engineers, they don't have that kind of luxury in most cases. An irrelevant null pointer check happening in a closed system which prevents a workflow from entering a rule name for a missing role, well that kind of overhead cannot be allowed because of the negative system impact. For them, the error isn't that at the time of processing the role was not correctly returned, the error was in the data entry side that allowed the workflow definition to save with the invalid role in the first place.

So rather than checking for a null and then reporting the missing but expected role (like I would have done for defensive programming), instead it is better to assume the role is returned correctly every time. If the null is ever returned, well that's a bug, but it is caused by some other code and not this point of failure. The code skips all of the overhead of the check, avoids catching exceptions that it can't really recover from anyway, and just lets the original NPE pass on up for someone else to deal with.

From our side, it can make our jobs as developers a little harder, but over time it will become easier. Me, I saw the NPE, looked at the line it was executing, figured out it was trying to fetch a role from the database that it wasn't finding, so I figured there was likely a role issue between the two. Process ends up being similar for every NPE you encounter in Liferay.