[jboss-user] [jBPM] - Exception when use ksession.abortProcessInstance(processId) with LocalTaskService without persisted process instance

Ted Pan do-not-reply at jboss.com
Fri Nov 2 15:52:56 EDT 2012


Ted Pan [https://community.jboss.org/people/ted.pan] created the discussion

"Exception when  use ksession.abortProcessInstance(processId) with LocalTaskService without persisted process instance"

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

--------------------------------------------------------------
hi,

When I use LocalTaskService without persisting process instance,  an exception will be thrown out when I use ksession.abortProcessInstance(processId);
(I use jbpm 5.4.0.CR1)

15:41:56,147 ERROR [com.mmm.sable.common.exceptionhandler.ErrorRedirectJSFPageHandler] (http--0.0.0.0-8080-2) 20121102071156147-816781937-- an error occurred : : javax.persistence.NonUniqueResultException: result returns more than one elements
    at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:298) [hibernate-entitymanager-4.1.7.Final.jar:4.1.7.Final]
    at org.jbpm.task.service.persistence.TaskPersistenceManager.queryWithParameters(TaskPersistenceManager.java:350) [jbpm-human-task-core-5.4.0.CR1.jar:5.4.0.CR1]
    at org.jbpm.task.service.persistence.TaskPersistenceManager.queryWithParametersInTransaction(TaskPersistenceManager.java:295) [jbpm-human-task-core-5.4.0.CR1.jar:5.4.0.CR1]
    at org.jbpm.task.service.TaskServiceSession.getTaskByWorkItemId(TaskServiceSession.java:752) [jbpm-human-task-core-5.4.0.CR1.jar:5.4.0.CR1]
    at org.jbpm.task.service.local.LocalTaskService.getTaskByWorkItemId(LocalTaskService.java:161) [jbpm-human-task-core-5.4.0.CR1.jar:5.4.0.CR1]
    at org.jbpm.process.workitem.wsht.GenericHTWorkItemHandler.abortWorkItem(GenericHTWorkItemHandler.java:203) [jbpm-human-task-core-5.4.0.CR1.jar:5.4.0.CR1]
    at org.drools.process.instance.impl.DefaultWorkItemManager.internalAbortWorkItem(DefaultWorkItemManager.java:89) [drools-core-5.5.0.CR1.jar:5.5.0.CR1]
    at org.jbpm.workflow.instance.node.WorkItemNodeInstance.cancel(WorkItemNodeInstance.java:257) [jbpm-flow-5.4.0.CR1.jar:5.4.0.CR1]




By comparing the DefaultWorkItemManager with JPAWorkItemManager, there are different logic to set the workitemid in task table.
in DefaultWorkItemManager, 
           ((WorkItemImpl) workItem).setId(workItemCounter.incrementAndGet());

the workitem's id will begin with 1 every time restart. but JPAWorkItemManager will use WorkItemInfo's ID, which will be unique for each workitem.
           WorkItemInfo workItemInfo = new WorkItemInfo(workItem, env);

        PersistenceContext context = ((PersistenceContextManager) env.get( EnvironmentName.PERSISTENCE_CONTEXT_MANAGER )).getCommandScopedPersistenceContext();
        context.persist( workItemInfo );

        ((WorkItemImpl) workItem).setId(workItemInfo.getId());


So the result is:
When try to cancel the process instance, because the workitem's id is always beginning with 1. there are many records in task table with workitemid = 1. then the exception(result returns more than one elements) happens.

is this by design, or is a bug?


Thanks
--------------------------------------------------------------

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

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20121102/4f383ea9/attachment.html 


More information about the jboss-user mailing list