2 Replies Latest reply on Jan 12, 2007 4:08 PM by Ajay Goel

    Couldn't parse process definition...

    Fidalma D'Ammando Newbie

      Hi all,
      I am always in trouble... sigh... This is the situation:

      -------------------------------------- PROCESS DEFINITION --------------------------------------
      
      <?xml version="1.0" encoding="UTF-8"?>
      <process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="Initiator">
       <swimlane name="initiator" />
       <start-state name="start new process">
       <task swimlane="process initiator" />
       <transition name="tr1" to="decision">
       <action name="action" class="com.sample.action.SampleActionHandler">
       </action>
       </transition>
       </start-state>
       <decision name="decision">
       <handler class="com.sample.decision.SampleDecisionHandler"></handler>
       <transition name="tr2" to="action"></transition>
       <transition name="tr3" to="end1"></transition>
       </decision>
       <state name="action">
       <transition name="tr4" to="end1"></transition>
       </state>
       <end-state name="end1"></end-state>
      </process-definition>
      
      
      ---------------------------------------- MY ACTION HANDLER --------------------------------------
      
      
      package com.sample.action;
      
      import org.jbpm.graph.def.ActionHandler;
      import org.jbpm.graph.exe.ExecutionContext;
      
      public class SampleActionHandler implements ActionHandler
      {
       private static final long serialVersionUID = 1L;
       public void execute(ExecutionContext context) throws Exception
       {
       Runtime rt = null;
       Process process = null;
      
       context.getContextInstance().createVariable("greeting", "Greeting from SampleActionHandler");
       try
       {
       rt = Runtime.getRuntime();
       process = rt.exec("C:\\Applications~1\\ECLIPSE~1\\Start.bat");
       context.getContextInstance().createVariable("status", new Integer(process.waitFor()));
       }
       catch (Exception e)
       {
       System.out.println(e);
       context.getContextInstance().createVariable("budget", new Integer(1));
       }
       }
      }
      
      
      ------------------------------------- MY DECISION HANDLER --------------------------------------
      
      
      package com.sample.decision;
      
      import org.jbpm.graph.exe.ExecutionContext;
      import org.jbpm.graph.node.DecisionHandler;
      
      public class SampleDecisionHandler implements DecisionHandler
      {
       private static final long serialVersionUID = 1L;
       public String decide(ExecutionContext context) throws Exception
       {
       int budget = ((Number)context.getContextInstance().getVariable("status")).intValue();
       if (budget == 0) return "tr2";
       else if (budget == 1) return "tr3";
       else return "tr3";
       }
      }
      
      
      ---------------------------------------- MY NEW CLASS ----------------------------------------
      
      
      package com.sample.util;
      
      import org.jbpm.graph.def.ProcessDefinition;
      import org.jbpm.graph.exe.ProcessInstance;
      
      public class StartProcess
      {
       private String path = "";
      
       /** Creates a new instance of StartProcess */
       private StartProcess()
       {
       path = "C:\\Applications and Projects\\ECLIPSE Workspace\\Process Initiator\\src\\" +
       "process\\Initiator.par\\processdefinition.xml";
       }
      
      
       public void init()
       {
       try
       {
       ProcessDefinition def = ProcessDefinition.parseXmlResource(path);
       System.out.println("STEP 1 - Istanziata la classe ProcessDefinition");
      
       ProcessInstance instance = new ProcessInstance(def);
       System.out.println("STEP 2 - Istanziata la classe ProcessInstance");
      
       instance.signal();
       System.out.println("STEP 3 - Effettuato il primo signal");
       }
       catch(Exception e)
       {
       System.err.println(e.getMessage());
       //e.printStackTrace();
       }
       }
      
      
       public static void main(String[] args)
       {
       try
       {
       StartProcess sp = new StartProcess();
       System.out.println("STEP 0 - Istanziata la classe StartProcess");
       System.out.println(sp.path);
       sp.init();
       }
       catch(Exception exc)
       {
       System.err.println(exc.getMessage());
       exc.printStackTrace();
       }
       }
      }
      


      When I try to execute my class "StartProcess" then I have the error "Couldn't parse process definition...". This is the output:

      [java] STEP 0 - Istanziata la classe StartProcess
      [java] C:\Applications and Projects\ECLIPSE Workspace\Process Initiator\src\process\Initiator.par\processdefinition.xml
      [java] 11:46:44,190 [main] INFO JbpmConfiguration : using jbpm configuration resource 'jbpm.cfg.xml'
      [java] 11:46:44,737 [main] DEBUG JbpmConfiguration : creating jbpm configuration from input stream
      [java] 11:46:44,831 [main] ERROR JpdlXmlReader : couldn't parse process definition
      [java] org.dom4j.DocumentException: null Nested exception: null
      [java] at org.dom4j.io.SAXReader.read(SAXReader.java:484)
      [java] at org.jbpm.jpdl.xml.JpdlParser.parse(JpdlParser.java:57)
      [java] at org.jbpm.jpdl.xml.JpdlXmlReader.readProcessDefinition(JpdlXmlReader.java:138)
      [java] at org.jbpm.graph.def.ProcessDefinition.parseXmlInputStream(ProcessDefinition.java:172)
      [java] at org.jbpm.graph.def.ProcessDefinition.parseXmlResource(ProcessDefinition.java:153)
      [java] at com.sample.util.StartProcess.init(StartProcess.java:22)
      [java] at com.sample.util.StartProcess.main(StartProcess.java:47)
      [java] Nested exception:
      [java] [[ERROR] couldn't parse process definition]
      [java] java.net.MalformedURLException
      [java] at java.net.URL.(URL.java:571)
      [java] at java.net.URL.(URL.java:434)
      [java] at java.net.URL.(URL.java:383)
      [java] at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
      [java] at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
      [java] at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      [java] at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      [java] at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
      [java] at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
      [java] at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
      [java] at org.dom4j.io.SAXReader.read(SAXReader.java:465)
      [java] at org.jbpm.jpdl.xml.JpdlParser.parse(JpdlParser.java:57)
      [java] at org.jbpm.jpdl.xml.JpdlXmlReader.readProcessDefinition(JpdlXmlReader.java:138)
      [java] at org.jbpm.graph.def.ProcessDefinition.parseXmlInputStream(ProcessDefinition.java:172)
      [java] at org.jbpm.graph.def.ProcessDefinition.parseXmlResource(ProcessDefinition.java:153)
      [java] at com.sample.util.StartProcess.init(StartProcess.java:22)
      [java] at com.sample.util.StartProcess.main(StartProcess.java:47)


      Could someone explain to me why I'm having this error and what do I have to do to solve it ?

      Thank you very much in advance !!

      Regards,
      Fidalma
      Italy