在mysql中发布了流程后,使用:
public static void main(String[] args) {
JbpmContext jbpmContext = JbpmConfiguration.getInstance().createJbpmContext();
try{
GraphSession graphSession = jbpmContext.getGraphSession();
//获取流程实例,这样是从数据库中解析流程实例的最后版本
ProcessDefinition definition = graphSession.findLatestProcessDefinition("jbpm");
//这里注释掉的是原来使用的代码,这样的话用的是spring生成的流程定义对象,是从xml解析来的
// ProcessInstance pi = new ProcessInstance(jbpmTemplate.getProcessDefinition());
ProcessInstance pi = definition.createProcessInstance();
pi.signal();
}
finally{
jbpmContext.close();
}
}
使用流程后报了个莫名其妙的问题,应该是找不到去下个节点的路径吧:
Exception in thread "main" org.jbpm.JbpmException: couldn't signal token 'Token(/)' : node 'StartState(start-state1)' doesn't have a default transition
at org.jbpm.graph.exe.Token.signal(Token.java:148)
at org.jbpm.graph.exe.ProcessInstance.signal(ProcessInstance.java:305)
at com.huang.jbpm.test.testDB.main(testDB.java:20)
下面是processdefinition.xml内容:
<?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="" name="jbpm">
<start-state name="start-state1">
<transition to="state1"></transition>
</start-state>
<state name="state1">
<transition to="end-state1"></transition>
</state>
<end-state name="end-state1"></end-state>
</process-definition>
------解决方案--------------------------------------------------------
测试了一下你贴的代码,在我的服务器上跑没出现问题。建议你换个运行环境跑下,对比就知道问题所在了。