[jboss-user] [JBoss jBPM] - closed JbpmContext in different order then they were created
dovetail
do-not-reply at jboss.com
Wed Jul 16 07:43:32 EDT 2008
I have the following code snippet which loads a process instance, loops for unfinished tasks and ends them
In JBPM 3.1.4 this code works fine, but in 3.2.2 it fails with the following error
Caused by: org.jbpm.JbpmException: closed JbpmContext in different order then they were created... check your try-finally's around JbpmContexts blocks
The error is on the jbpmContext.close() in the finally block
The log.debug points show that the correct context is created initially, but a new context is created within the taskInstance.end() code and this has
been added to the stack causing the error to occur.
Can you please shed some light on how this should be handled?
Thanks
public void endTask( Long processId ) {
| JbpmContext jbpmContext = JbpmConfiguration.getInstance().createJbpmContext();
| log.debug( "Current context 1" + JbpmConfiguration.getInstance().getCurrentJbpmContext().toString() );
| try {
| ProcessInstance processInstance = jbpmContext.loadProcessInstance( processId );
| List<TaskInstance> taskInstanceList = (List<TaskInstance>)processInstance.getTaskMgmtInstance().getUnfinishedTasks( processInstance.getRootToken() );
| for ( TaskInstance taskInstance : taskInstanceList ) {
| log.debug( "Current context 2" + JbpmConfiguration.getInstance().getCurrentJbpmContext().toString() );
| taskInstance.end();
| log.debug( "Current context 3" + JbpmConfiguration.getInstance().getCurrentJbpmContext().toString() );
| }
| } finally {
| log.debug( "Current context 4" + JbpmConfiguration.getInstance().getCurrentJbpmContext().toString() );
| log.debug( "Closing context" +jbpmContext.toString() );
| jbpmContext.close();
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4164723#4164723
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4164723
More information about the jboss-user
mailing list