[jboss-user] [JBoss jBPM] - Re: Un expected behavior observed with Token details

malish do-not-reply at jboss.com
Wed May 23 23:36:07 EDT 2007


Until an appropriate solution is found or reply is received from JBoss, we have just decided to apply the following local fix.
Again this is related to loss of Node after Exception is thrown within the custom ActionHandler. 
All we do is saving the Node object before calling token.signal() method. When we catch the Exception and if new value of getNode() is NULL, we store the saved copy of the Node. Sample code is below:

public void processWorkflowEvent(long pid, String eventName) throws ...
  | {
  |   JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
  |   JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
  |   try
  |   {
  |      ... your own code
  |      ProcessInstance process = jbpmContext.getProcessInstanceForUpdate(pid);
  |     Token token = process.getRootToken();
  |     // save the node
  |     Node nodeSaved = token.getNode();
  | 
  |     // process  signal
  |     try
  |     {
  |        token.signal(eventName);
  |     }
  |     catch(Exception e)
  |     {
  |        if(token.getNode() == null)
  |        {
  |           // node is lost due to JBPM internals
  |           // restore the node
  |           token.setNode(nodeSaved);
  |         }
  |         ...
  |      }
  |   }
  |   catch(Exception e)
  |   {
  |      // do whatever you need to handle own exceptions
  |   }
  |   finally
  |   {
  |      jbpmContext.close();
  |   }
  | }

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048111#4048111

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4048111



More information about the jboss-user mailing list