jbpm解析流程的方法问题

jbpm解析流程常见有两种方法
 
   方法一:直接加载流程定义,代码如下,我已经测试通过了
package org.jbpm.tutorial.helloworld;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token;
import junit.framework.TestCase;
public class HelloWorldTest extends TestCase {
 public void testHelloWorldProcess() {
  //方式一:加载流程的方法
  /**
  ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
    "<process-definition>" +
    " <start-state>" +
    " <transition to='s' />" +
    " </start-state>" +
    " <state name='s'>" +
    " <transition to='end' />" +
    " </state>" +
    " <end-state name='end' />" +
    "</process-definition>");
    
    */
 
    
    //方式二:加载流程二的方法
  ///ProcessDefinition processDefinition=ProcessDefinition.parseXmlResource("process/test/processdefinition.xml");
 
  ProcessInstance processInstance =new ProcessInstance(processDefinition);
  Token token = processInstance.getRootToken();
  /*
  当然,构造以后,流程定义的主要的执行路径被定位在开始状态(start-state)
  */
  assertSame(processDefinition.getStartState(), token.getNode());
  System.out.println(token.getNode().getName());
  /*
  开始流程执行,通过默认的转换(transition)离开开始状态(start-state)
  */
  token.signal();
  System.out.println(token.getNode().getName());
  assertSame(processDefinition.getNode("s"), token.getNode());
  /*
  执行signal,流程将继续执行,将通过默认的转换(transition)离开状态‘s’
  */
  token.signal();
  System.out.println(token.getNode().getName());
  /*
  流程实例已经到达了结束状态。
  */
  assertSame(processDefinition.getNode("end"), token.getNode());
 }
 public static void main(String args[])
 {
  HelloWorldTest hwt=new HelloWorldTest();
  hwt.testHelloWorldProcess();
 }
}
方法二:解析流程定义的xml文件,从而获取流程,在这里我测试了却出现问题,上面代码二有我的解析xml方法,运行出现如下异常:
【AppLog】 10:51:05,781 INFO  using jbpm configuration resource 'jbpm.cfg.xml'
【AppLog】 10:51:05,921 ERROR couldn't parse process definition
org.dom4j.DocumentException: null Nested exception: null
 at org.dom4j.io.SAXReader.read(SAXReader.java:484)
 at org.jbpm.jpdl.xml.JpdlParser.parse(JpdlParser.java:57)
 at org.jbpm.jpdl.xml.JpdlXmlReader.readProcessDefinition(JpdlXmlReader.java:138)
 at org.jbpm.graph.def.ProcessDefinition.parseXmlInputStream(ProcessDefinition.java:172)
 at org.jbpm.graph.def.ProcessDefinition.parseXmlResource(ProcessDefinition.java:153)
 at org.jbpm.tutorial.helloworld.HelloWorldTest.testHelloWorldProcess(HelloWorldTest.java:28)
 at org.jbpm.tutorial.helloworld.HelloWorldTest.main(HelloWorldTest.java:56)
Nested exception:
java.net.MalformedURLException
 at java.net.URL.<init>(URL.java:601)
 at java.net.URL.<init>(URL.java:464)
 at java.net.URL.<init>(URL.java:413)
 at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
 at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
 at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
 at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
 at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
 at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
 at org.dom4j.io.SAXReader.read(SAXReader.java:465)
 at org.jbpm.jpdl.xml.JpdlParser.parse(JpdlParser.java:57)
 at org.jbpm.jpdl.xml.JpdlXmlReader.readProcessDefinition(JpdlXmlReader.java:138)
 at org.jbpm.graph.def.ProcessDefinition.parseXmlInputStream(ProcessDefinition.java:172)
 at org.jbpm.graph.def.ProcessDefinition.parseXmlResource(ProcessDefinition.java:153)
 at org.jbpm.tutorial.helloworld.HelloWorldTest.testHelloWorldProcess(HelloWorldTest.java:28)
 at org.jbpm.tutorial.helloworld.HelloWorldTest.main(HelloWorldTest.java:56)
Exception in thread "main" org.jbpm.jpdl.JpdlException: [[ERROR] couldn't parse process definition]
 at org.jbpm.jpdl.xml.JpdlXmlReader.readProcessDefinition(JpdlXmlReader.java:163)
 at org.jbpm.graph.def.ProcessDefinition.parseXmlInputStream(ProcessDefinition.java:172)
 at org.jbpm.graph.def.ProcessDefinition.parseXmlResource(ProcessDefinition.java:153)
 at org.jbpm.tutorial.helloworld.HelloWorldTest.testHelloWorldProcess(HelloWorldTest.java:28)
 at org.jbpm.tutorial.helloworld.HelloWorldTest.main(HelloWorldTest.java:56)
如果你知道,就请告诉我
 

本文出自 “gjhgkh” 博客,谢绝转载!

你可能感兴趣的:(职场,休闲)