3 Replies Latest reply on Sep 17, 2010 8:24 AM by rebody

    java.lang.NullPointerException on Notification sent

    gonlafer

      Hello,

       

      I've got the following problem using JBPM 4.4:

       

      I have a flow started and the first task assignee is set as a process variable in the following way:

       

      <task g="196,322,132,52" name="Submit adjustment for approval" candidate-groups="AdjustmentsInitiator" assignee="#{initiator}">
            <notification/>
            <reminder duedate="1 hour" repeat="1 hour"/>
            <transition g="-64,-12" name="submit" to="change_status_to_submitted"/>
            <transition g="-155,-18" name="cancel" to="change_status_to_cancelled"/>
         </task>

       

      This is working perfectly and the assignee get a mail advising on the task assignment.

       

      However, if the assignee releases the task (ts.assignTask(taskId, null);) I get the following error:

       

      java.lang.NullPointerException
          at org.jbpm.pvm.internal.email.impl.MailProducerImpl.tokenizeActors(MailProducerImpl.java:148)
          at org.jbpm.pvm.internal.email.impl.MailProducerImpl.fillRecipients(MailProducerImpl.java:194)
          at org.jbpm.pvm.internal.email.impl.MailProducerImpl.fillRecipients(MailProducerImpl.java:166)
          at org.jbpm.pvm.internal.email.impl.MailProducerImpl.produce(MailProducerImpl.java:82)
          at org.jbpm.jpdl.internal.activity.MailListener.notify(MailListener.java:58)
          at org.jbpm.pvm.internal.model.op.ExecuteEventListener.perform(ExecuteEventListener.java:81)
          at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperationSync(ExecutionImpl.java:672)
          at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperation(ExecutionImpl.java:632)
          at org.jbpm.pvm.internal.model.ExecutionImpl.fire(ExecutionImpl.java:579)
          at org.jbpm.pvm.internal.model.ExecutionImpl.fire(ExecutionImpl.java:568)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      ....

       

      Is there any way to remove the task assignment without the notifications being sent?

       

      The test I've done is quite simple:

       

      @Test
          public void testReAssignTask() {
              TaskService ts = processEngine.getTaskService();
              String taskId = "490009";
              Task task = ts.getTask(taskId);
              logger.debug(task.getAssignee());
              ts.assignTask(taskId, null);
          }

       

      Thanks,
      Gonzalo

        • 1. Re: java.lang.NullPointerException on Notification sent
          rebody

          Hi Gonzalo,

           

            Thank you for the testcase,  I open an issue and attach a patch for this.  when there is no assignee with notification element,  there will cause an JbpmException.  Please let me know what do you think about this.  Thank you very much.

           

          https://jira.jboss.org/browse/JBPM-2940

          • 2. Re: java.lang.NullPointerException on Notification sent
            gonlafer

            Hello,

             

            not sure if that approach will solve the problem. In my opinion, task assignee should be removed, notification should not be sent and no Exception should be raised. Only in the case where assignee is populated (not null or empty), the notification is sent.

             

            Thanks,
            Gonzalo

            • 3. Re: java.lang.NullPointerException on Notification sent
              rebody

              Hi Gonzalo,

                Because the ${task.assignee} maybe not the only one reciepent of notification mail.  Maybe someone custom his own mail-template. and make more recipients for the notification mail.  So we cannot skip mail sending just when the task assignee is null.

                I know my patch is not good enough, but at least it provide a more clearly message to people who want  to use this feature to send notfication mail.

               

                Maybe you could give us more information about it.  Thank you very much.