日期:2014-05-19  浏览次数:20842 次

JBPM3 token 'Token(/)'can't be signalled cause it is currently not positioned
Java code

    public void testDeployProcessDefinition(){
        
        JbpmContext context = configuration.createJbpmContext() ;
        try {
            ProcessDefinition pd = new ProcessDefinition(processDefinitionName) ;
            JbpmUtil.deployProcessDefinition(context, pd) ;
        } catch (Exception e) {
            context.setRollbackOnly() ;
            e.printStackTrace();
        }finally{
            context.close() ;
        }
    }

public void testStartNewProcessInstance(){
        JbpmContext context = configuration.createJbpmContext() ;
        try {
            ProcessInstance pi = JbpmUtil.startNewProcessInstance(context, processDefinitionName) ;
            System.out.println("Current ProcessInstance Id : "+pi.getId());
        } catch (Exception e) {
            context.setRollbackOnly() ;
            e.printStackTrace();
        }finally{
            context.close() ;
        }
    }

public void testFinishFullProcessInstace(){
        JbpmContext context = configuration.createJbpmContext() ;
        try {
            JbpmUtil.finishFullProcessInstace(context) ;
        } catch (Exception e) {
            context.setRollbackOnly() ;
            e.printStackTrace();
        }finally{
            context.close() ;
        }
    }
    
public static void finishFullProcessInstace(JbpmContext context){
        
        ProcessInstance pi = context.getProcessInstance(DataUtil.getProcessInstanceId()) ;
        
        context.getSession().setFlushMode(FlushMode.ALWAYS) ;
 
        while( ! ( pi.getRootToken().getNode() instanceof EndState ) ){
            Node node = pi.getRootToken().getNode() ;
            if( node instanceof StartState ){
                System.out.println("StartState : "+node.getName());
                pi.signal() ;
            }else if(node instanceof State){
                System.out.println("State : "+node.getName());
                pi.signal() ;
            }else if(node instanceof TaskNode){
                System.out.println("TaskNode : "+node.getName());
                pi.signal() ;
            }else if(node instanceof Node){
                System.out.println(" Node : "+node.getName());
            }else{
                System.out.println("Unknown Node : "+node.getName() );
            }
        } 
 
    }



流程定义文件:
<?xml version="1.0" encoding="UTF-8"?>

<process-definition
  xmlns="" name="qingjia">
  <start-state name="start">
  <transition name="" to="state1"></transition>
  </start-state>
  <state name="state1">
  <transition name="" to="task1"></transition>
  </state>
  <task-node name="task1">
  <transition name="" to="end1"></transition>
  </task-node>
  <end-state name="end1"></end-state>
</process-definition>

当我部署完流程定义后(testDeployProcessDefinition()),然后开始一个流程实例(testStartNewProcessInstance()),当先把流程跑一边的时候,总是报如标题的错误。请问是哪里调用有问题啊?
org.jbpm.JbpmException: token 'Token(/)' can't be signalled cause it is currently not positioned in a node
at org.jbpm.graph.exe.Token.signal(Token.java:134)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invo