7 Replies Latest reply on Feb 22, 2013 10:27 AM by diaguirr

    Error on task complete.

    diaguirr

      I am working with JBPM 5.1 , integrated with the ESB 4.11 and the AS 5. Actualy, its the enterprise confirguration for this products (SOA-P 5.3 + its JBPM5 integration)

      Untill now i have been using some services wich start a single process each one. Those process are fairly complex and include human tasks. This setup was working quite well untill we started using bpmn process to orchestrate those services on more complex ones.

      So now we have a service wich starts a process wich calls another service wich start a process with human tasks on it. In this scenario, some times (most times actually) when we complete a human task, an error is thrown in the console, but apparently the task completes normally.

      We have experenced some task duplication and taks not being created, and we think this error might be cousing that.

      The error trace is the following:

       

      15:40:15,823 ERROR [SingleSessionCommandService] Could not commit session

      java.lang.NullPointerException

          at org.jbpm.process.instance.impl.ProcessInstanceImpl.setProcess(ProcessInstanceImpl.java:61)

          at org.jbpm.marshalling.impl.AbstractProtobufProcessInstanceMarshaller.readProcessInstance(AbstractProtobufProcessInstanceMarshaller.java:375)

          at org.jbpm.persistence.processinstance.ProcessInstanceInfo.getProcessInstance(ProcessInstanceInfo.java:142)

          at org.jbpm.persistence.processinstance.JPAProcessInstanceManager.getProcessInstance(JPAProcessInstanceManager.java:83)

          at org.jbpm.process.instance.ProcessRuntimeImpl.getProcessInstance(ProcessRuntimeImpl.java:204)

          at org.drools.common.AbstractWorkingMemory.getProcessInstance(AbstractWorkingMemory.java:1100)

          at org.drools.impl.StatefulKnowledgeSessionImpl.getProcessInstance(StatefulKnowledgeSessionImpl.java:295)

          at org.drools.persistence.jpa.processinstance.JPAWorkItemManager.completeWorkItem(JPAWorkItemManager.java:117)

          at org.drools.command.runtime.process.CompleteWorkItemCommand.execute(CompleteWorkItemCommand.java:69)

          at org.drools.command.runtime.process.CompleteWorkItemCommand.execute(CompleteWorkItemCommand.java:32)

          at org.drools.command.impl.DefaultCommandService.execute(DefaultCommandService.java:36)

          at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:355)

          at org.drools.command.impl.CommandBasedStatefulKnowledgeSession$1.completeWorkItem(CommandBasedStatefulKnowledgeSession.java:150)

          at org.jbpm.task.service.hornetq.CommandBasedHornetQWSHumanTaskHandler$GetResultContentResponseHandler.execute(CommandBasedHornetQWSHumanTaskHandler.java:309)

          at org.jbpm.task.service.TaskClientHandler.messageReceived(TaskClientHandler.java:153)

          at org.jbpm.task.service.hornetq.HornetQTaskClientHandler.messageReceived(HornetQTaskClientHandler.java:56)

          at org.jbpm.task.service.hornetq.HornetQTaskClientConnector$1.run(HornetQTaskClientConnector.java:108)

          at java.lang.Thread.run(Unknown Source)

      15:40:16,630 ERROR [STDERR] Exception in thread "Thread-86"

      15:40:16,630 ERROR [STDERR] java.lang.RuntimeException: Client Exception with class class org.jbpm.task.service.hornetq.HornetQTaskClientConnector$1 using port 5446

      15:40:16,630 ERROR [STDERR]     at org.jbpm.task.service.hornetq.HornetQTaskClientConnector$1.run(HornetQTaskClientConnector.java:119)

      15:40:16,630 ERROR [STDERR]     at java.lang.Thread.run(Unknown Source)

      15:40:16,630 ERROR [STDERR] Caused by: java.lang.NullPointerException

      15:40:16,630 ERROR [STDERR]     at org.jbpm.process.instance.impl.ProcessInstanceImpl.setProcess(ProcessInstanceImpl.java:61)

      15:40:16,630 ERROR [STDERR]     at org.jbpm.marshalling.impl.AbstractProtobufProcessInstanceMarshaller.readProcessInstance(AbstractProtobufProcessInstanceMarshaller.java:375)

      15:40:16,630 ERROR [STDERR]     at org.jbpm.persistence.processinstance.ProcessInstanceInfo.getProcessInstance(ProcessInstanceInfo.java:142)

      15:40:16,630 ERROR [STDERR]     at org.jbpm.persistence.processinstance.JPAProcessInstanceManager.getProcessInstance(JPAProcessInstanceManager.java:83)

      15:40:16,630 ERROR [STDERR]     at org.jbpm.process.instance.ProcessRuntimeImpl.getProcessInstance(ProcessRuntimeImpl.java:204)

      15:40:16,630 ERROR [STDERR]     at org.drools.common.AbstractWorkingMemory.getProcessInstance(AbstractWorkingMemory.java:1100)

      15:40:16,630 ERROR [STDERR]     at org.drools.impl.StatefulKnowledgeSessionImpl.getProcessInstance(StatefulKnowledgeSessionImpl.java:295)

      15:40:16,630 ERROR [STDERR]     at org.drools.persistence.jpa.processinstance.JPAWorkItemManager.completeWorkItem(JPAWorkItemManager.java:117)

      15:40:16,630 ERROR [STDERR]     at org.drools.command.runtime.process.CompleteWorkItemCommand.execute(CompleteWorkItemCommand.java:69)

      15:40:16,630 ERROR [STDERR]     at org.drools.command.runtime.process.CompleteWorkItemCommand.execute(CompleteWorkItemCommand.java:32)

      15:40:16,630 ERROR [STDERR]     at org.drools.command.impl.DefaultCommandService.execute(DefaultCommandService.java:36)

      15:40:16,630 ERROR [STDERR]     at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:355)

      15:40:16,630 ERROR [STDERR]     at org.drools.command.impl.CommandBasedStatefulKnowledgeSession$1.completeWorkItem(CommandBasedStatefulKnowledgeSession.java:150)

      15:40:16,630 ERROR [STDERR]     at org.jbpm.task.service.hornetq.CommandBasedHornetQWSHumanTaskHandler$GetResultContentResponseHandler.execute(CommandBasedHornetQWSHumanTaskHandler.java:309)

      15:40:16,630 ERROR [STDERR]     at org.jbpm.task.service.TaskClientHandler.messageReceived(TaskClientHandler.java:153)

      15:40:16,630 ERROR [STDERR]     at org.jbpm.task.service.hornetq.HornetQTaskClientHandler.messageReceived(HornetQTaskClientHandler.java:56)

      15:40:16,630 ERROR [STDERR]     at org.jbpm.task.service.hornetq.HornetQTaskClientConnector$1.run(HornetQTaskClientConnector.java:108)

      15:40:16,630 ERROR [STDERR]     ... 1 more

       

      As the log shows i am usng CommandBasedHornetQWSHumanTaskHandler as the human task work item handler and HornetQTaskClientConnector as the client conector for completing the task (but this happens too if i use the eclipse client).

      For starting the process i am using the Bpm5Processor action.

      I have been trying to solve this issue for several days now, so any idea or pointer is very welcome.

        • 1. Re: Error on task complete.
          roxy1987

          Why are you still using version 5.1. A lot of fixes are there in version 5.4

          • 2. Re: Error on task complete.
            diaguirr

            5.1 is  the JBPM version that is included as an add-on for the enterprise version of the soa server, so we want to avoid unnecessary change of versions if possible becouse that setup is supposed to be certified.

            • 3. Re: Error on task complete.
              roxy1987

              Ok. Are you using the same name for the task client everytime?

              Just try to use a random name for task client while creating the client object. Something like following :

               

               

              String name = "client 1" ++UUID.randomUUID();
              TaskClient client = new TaskClient(new HornetQTaskClientConnector(name, new HornetQTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));
              

               

              Regards.

              • 4. Re: Error on task complete.
                roxy1987

                Also just dispose or disconnect the client evertime after its usage. May be you can put the code in finally for each method.

                • 5. Re: Error on task complete.
                  diaguirr

                  We are already using diferent random names for the TaskClient and its is being closed after every access (query or task modifications).

                  • 6. Re: Error on task complete.
                    roxy1987

                    Can you try to use the same code with jbpm 5.4? Just for the proof of it. I read the same stack somewhere and there is a chance that this may be a bug in 5.1.

                    • 7. Re: Error on task complete.
                      diaguirr

                      We finally managed to fix this problem so i post here what we did.

                      Before i describe our solution, further test shows that this happens on every scenario we could think of where there where more than one process active at the same time, created with diferent sessions. (subrpocess, creatted form services, by raw java code, etc...) which is explicitly supported according to the documentation.

                       

                      First, since it was the only option we had left, we decided to try upgrading the bpm version to 5.4. As we are using an integrated enviroment inside a SOA-P server, we couldnt upgrade all the classes since the integration between JBPM5 and the ESB (jbossesb-bpm5.jar) has not a newer version we could find.

                      The first problem we had was that the class CommandBasedHornetQWSHumanTaskHandler, that is the only WorkItemHandler that actually works with the default integration class (Bpm5Processor), isn´t just deprecated, but broken. Apparently the serialization mechanism on the human task service has changed since 5.1, but only the srerialization methods on CommandBasedHornetQWSHumanTaskHandler has been updated, but the deserialization ones haven't. Indignation asside, this "half updated class" was still the only class that kind of works (HornetQHTWorkItemHandler throws time out exception when trying to create the task) so we fixed it ourselves.

                       

                      This being done, the application started working again as it was doing before the upgrade and the same error persisted (with a slithly diferent stack trace since the clases have changed).

                      After lots of tests and research we found the answer when we where trying to make HornetQHTWorkItemHandler work instead of CommandBasedHornetQWSHumanTaskHandler. Apparentrly, when there are more than one session simultaneously,  human task handlers are called many times form the different sessions that are alive, so, when you create a human task handler you must explicitly indicate that it must react only to events on its own session which for some reason isn't the default behavior. Even the CommandBasedHornetQWSHumanTaskHandler class has that option, but it isn't yet supported for the Bpm5Processor class, so we extended Bpm5Processor, setting it on true on every handler we create and this fixed the probelm. Sadly, this solutions wasn´t applicable to the version 5.1, at least not directly, since the old CommandBasedHornetQWSHumanTaskHandler doesn't have this option.

                       

                      Just for the record, this answer isn't in the expected secction of the documentation, the one about multiple sessions and processes, but in the human task handlers section as a note, which makes it very tricky to find, since it was not obviously a handler issue.