-
1. Re: [jbpm 4.2] My first simple application doesn't work :(
sebastian.s Dec 4, 2009 2:21 AM (in response to -silver-)You can't create process definitions programmatically this way anymore. Create a process definition and deploy it afterwards.
You need to reference jbpm.jar and the main-folder and all the jars in the lib-subfolder. -
2. Re: [jbpm 4.2] My first simple application doesn't work :(
sebastian.s Dec 4, 2009 2:22 AM (in response to -silver-)"in the main-folder"
-
3. Re: [jbpm 4.2] My first simple application doesn't work :(
-silver- Dec 4, 2009 5:00 AM (in response to -silver-)Sorry but I don't understood.
Could you tell me how I've to change the code of my previous application for example?
Thanks
(I referenced all the needed libraries now) -
4. Re: [jbpm 4.2] My first simple application doesn't work :(
saraswati.santanu Dec 5, 2009 5:18 AM (in response to -silver-)Silver,
the code you have written is wrong. It will not work that way. You need to create a Jpdl file first. You can use the Eclipse GPD for that. And then use the Jbpm API to create ProcessDefinition etc. There is no class called ProcessFactory in Jbpm4.
Second point that you need to understand is that a ProcessDefinition can not be started, it is the ProecessInstance which should be started.
Now assuming you have created a flow jpdl xml file, then your main class should look like this:private static ProcessEngine processEngine; private static RepositoryService repositoryService; private static ExecutionService executionService; static { processEngine = Configuration.getProcessEngine(); repositoryService = processEngine.get(RepositoryService.class); executionService = processEngine.getExecutionService(); } /** * @param args */ public static void main(String[] args) { //create new deployment object and ask it to deploy your flow String deploymentId = repositoryService.createDeployment().addResourceFromClasspath("sampleprocess.jpdl.xml").deploy(); //now we query the process definition ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deploymentId).uniqueResult(); //start the process instance with the Id of the process definition ProcessInstance processInstance = executionService.startProcessInstanceById(processDefinition.getId()); }
-
5. Re: [jbpm 4.2] My first simple application doesn't work :(
-silver- Dec 5, 2009 9:49 AM (in response to -silver-)Thanks!
I tried with your code but I received this exception:java.lang.ExceptionInInitializerError Caused by: org.jbpm.api.JbpmException: error: couldn't parse xml document : org.jbpm.api.JbpmException: resource jbpm.cfg.xml does not exist error: parsing exception: null : java.lang.NullPointerException at org.jbpm.pvm.internal.xml.ProblemList.getJbpmException(ProblemList.java:175) at org.jbpm.pvm.internal.xml.ProblemList.getJbpmException(ProblemList.java:141) at org.jbpm.pvm.internal.xml.Parse.checkErrors(Parse.java:190) at org.jbpm.pvm.internal.cfg.ProcessEngineImpl.parse(ProcessEngineImpl.java:222) at org.jbpm.pvm.internal.cfg.ProcessEngineImpl.setResource(ProcessEngineImpl.java:194) at org.jbpm.api.Configuration.setResource(Configuration.java:109) at org.jbpm.api.Configuration.getProcessEngine(Configuration.java:161) at prova.Main.<clinit>(Main.java:17) Caused by: org.jbpm.api.JbpmException at org.jbpm.pvm.internal.xml.ProblemList.getJbpmException(ProblemList.java:171) ... 7 more Caused by: java.lang.NullPointerException at org.jbpm.pvm.internal.util.XmlUtil.attribute(XmlUtil.java:289) at org.jbpm.pvm.internal.env.JbpmConfigurationParser.parseDocument(JbpmConfigurationParser.java:68) at org.jbpm.pvm.internal.xml.Parser.execute(Parser.java:396) at org.jbpm.pvm.internal.xml.Parse.execute(Parse.java:158) ... 5 more Exception in thread "main"
What could be the problem? Those are the two files of my project:
Main.javaimport org.jbpm.api.Configuration; import org.jbpm.api.ExecutionService; import org.jbpm.api.ProcessDefinition; import org.jbpm.api.ProcessEngine; import org.jbpm.api.ProcessInstance; import org.jbpm.api.RepositoryService; public class Main{ private static ProcessEngine processEngine; private static RepositoryService repositoryService; private static ExecutionService executionService; static { processEngine = Configuration.getProcessEngine(); repositoryService = processEngine.get(RepositoryService.class); executionService = processEngine.getExecutionService(); } /** * @param args */ public static void main(String[] args) { //create new deployment object and ask it to deploy your flow String deploymentId = repositoryService.createDeployment().addResourceFromClasspath("sampleprocess.jpdl.xml").deploy(); //now we query the process definition ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deploymentId).uniqueResult(); //start the process instance with the Id of the process definition ProcessInstance processInstance = executionService.startProcessInstanceById(processDefinition.getId()); } }
and sampleprocess.jpdl<?xml version="1.0" encoding="UTF-8"?> <process name="sampleprocess" xmlns="http://jbpm.org/4.0/jpdl"> <start name="start1" g="238,73,48,48"> <transition name="to end1" to="end1" g="-45,-20"/> </start> <end name="end1" g="267,271,48,48"/> </process>
Regarding to files that I described in my precedent post, I copied them directly from the PVM documentation, (Page 5 - 6 chapter 2). Could you send me the link to the correct PVM documentation?
Thanks! -
6. Re: [jbpm 4.2] My first simple application doesn't work :(
saraswati.santanu Dec 5, 2009 1:58 PM (in response to -silver-)You are missing jbpm.cfg.xml file in your classpath. A very simple jbpm.cfg.xml may look like this:
<?xml version="1.0" encoding="UTF-8"?> <jbpm-configuration> <import resource="jbpm.default.cfg.xml" /> <import resource="jbpm.tx.hibernate.cfg.xml" /> <import resource="jbpm.jpdl.cfg.xml" /> <import resource="jbpm.identity.cfg.xml" /> <!-- Job executor is excluded for running the example test cases. --> <!-- To enable timers and messages in production use, this should be included. --> <!-- <import resource="jbpm.jobexecutor.cfg.xml" /> --> </jbpm-configuration>
Create one such file in you classpath. That should make things progress further.
About the PVM documentation,the one they have there has examples using jbpm3.x. In 3.x there were those APIs. Jbpm4, I think, was not there when PVM docs were created. You should look at Jbpm dev-guide, user-guide and example with Jbpm4 instead.