Discussion:
[jboss-user] [jBPM] - Error on task complete.
Diego Aguirre
2013-02-18 18:52:58 UTC
Permalink
Diego Aguirre [https://community.jboss.org/people/diaguirr] created the discussion

"Error on task complete."

To view the discussion, visit: https://community.jboss.org/message/798218#798218

--------------------------------------------------------------
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.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/798218#798218]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
roxy1987
2013-02-19 15:15:32 UTC
Permalink
roxy1987 [https://community.jboss.org/people/roxy1987] created the discussion

"Re: Error on task complete."

To view the discussion, visit: https://community.jboss.org/message/798367#798367

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

Reply to this message by going to Community
[https://community.jboss.org/message/798367#798367]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Diego Aguirre
2013-02-19 18:49:17 UTC
Permalink
Diego Aguirre [https://community.jboss.org/people/diaguirr] created the discussion

"Re: Error on task complete."

To view the discussion, visit: https://community.jboss.org/message/798402#798402

--------------------------------------------------------------
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.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/798402#798402]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
roxy1987
2013-02-19 21:36:49 UTC
Permalink
roxy1987 [https://community.jboss.org/people/roxy1987] created the discussion

"Re: Error on task complete."

To view the discussion, visit: https://community.jboss.org/message/798425#798425

--------------------------------------------------------------
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.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/798425#798425]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
roxy1987
2013-02-19 21:39:52 UTC
Permalink
roxy1987 [https://community.jboss.org/people/roxy1987] created the discussion

"Re: Error on task complete."

To view the discussion, visit: https://community.jboss.org/message/798427#798427

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

Reply to this message by going to Community
[https://community.jboss.org/message/798427#798427]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Diego Aguirre
2013-02-20 14:16:25 UTC
Permalink
Diego Aguirre [https://community.jboss.org/people/diaguirr] created the discussion

"Re: Error on task complete."

To view the discussion, visit: https://community.jboss.org/message/798586#798586

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

Reply to this message by going to Community
[https://community.jboss.org/message/798586#798586]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
roxy1987
2013-02-21 14:19:21 UTC
Permalink
roxy1987 [https://community.jboss.org/people/roxy1987] created the discussion

"Re: Error on task complete."

To view the discussion, visit: https://community.jboss.org/message/798840#798840

--------------------------------------------------------------
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.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/798840#798840]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Diego Aguirre
2013-02-22 15:27:41 UTC
Permalink
Diego Aguirre [https://community.jboss.org/people/diaguirr] created the discussion

"Re: Error on task complete."

To view the discussion, visit: https://community.jboss.org/message/799109#799109

--------------------------------------------------------------
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.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/799109#799109]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Loading...