-
2. Re: jbpm 4.0 creating and running processes without persiste
thirumalvishnu Jul 17, 2009 10:03 AM (in response to thirumalvishnu)Hi,
Thanks for the info. I tried with that section . But it seems in background it uses hibernate to deploy the process .
During run time I get the following log
[DriverManagerConnectionProvider] Using Hibernate built-in connection pool (not for production use!)
Is there any way to remove persistence dependency compeletly and is there any Client API samples which works with process and execution objects directly -
3. Re: jbpm 4.0 creating and running processes without persiste
thirumalvishnu Jul 20, 2009 1:34 AM (in response to thirumalvishnu)Hi,
I am still stuck with this . Can anybody help me ? -
4. Re: jbpm 4.0 creating and running processes without persiste
kukeltje Jul 20, 2009 6:54 AM (in response to thirumalvishnu)not yet, planned for a future (minor) release, e.g. jbpm 4.1 or 4.2. See the jira
-
5. Re: jbpm 4.0 creating and running processes without persiste
thirumalvishnu Jul 20, 2009 8:57 AM (in response to thirumalvishnu)Hi Roland,
Can you give any additional info ?(like JIRA ref url. I tried searching JIRA but was not able to find requiremtns specific to my need) that would be of much helpful to me. -
6. Re: jbpm 4.0 creating and running processes without persiste
mihail Jul 24, 2009 3:10 PM (in response to thirumalvishnu)I managed to run a process without persistence.
Here is the code:import junit.framework.TestCase; import org.jbpm.jpdl.internal.model.JpdlProcessDefinition; import org.jbpm.jpdl.internal.xml.JpdlParser; import org.jbpm.jpdl.internal.activity.StartActivity; import org.jbpm.jpdl.internal.activity.StateActivity; import org.jbpm.jpdl.internal.activity.EndActivity; import org.jbpm.pvm.internal.model.ActivityImpl; import org.jbpm.pvm.internal.model.TransitionImpl; import org.jbpm.pvm.internal.model.ProcessDefinitionImpl; import org.jbpm.pvm.internal.client.ClientExecution; import org.jbpm.pvm.internal.xml.Parse; import org.jbpm.api.activity.ActivityExecution; import org.jbpm.api.activity.ExternalActivityBehaviour; import java.io.FileInputStream; import java.io.IOException; import java.util.Map; public class HelloWorldTest extends TestCase { public void test_helloWorldProcess() throws IOException { ProcessDefinitionImpl processDefinition = createProcessDefinition(); ClientExecution execution = processDefinition.startProcessInstance(); System.out.println("State After start : " + execution.findActiveActivityNames()); execution.signal(); System.out.println("State after signal: " + execution.findActiveActivityNames()); } private ProcessDefinitionImpl createProcessDefinition() { ProcessDefinitionImpl processDefinition = new ProcessDefinitionImpl(); processDefinition.setName("hello"); //define states ActivityImpl start = processDefinition.createActivity("start"); start.setBehaviour(new StartActivity()); //it turns out is very important to call this since it says where the process starts processDefinition.setInitial(start); ActivityImpl state1 = processDefinition.createActivity("state1"); state1.setBehaviour(new HelloActivity()); ActivityImpl state2 = processDefinition.createActivity("state2"); state2.setBehaviour(new StateActivity()); ActivityImpl end = processDefinition.createActivity("end"); end.setBehaviour(new EndActivity()); //define transitions TransitionImpl transition = start.createOutgoingTransition(); transition.setDestination(state1); TransitionImpl transition2 = state1.createOutgoingTransition(); transition2.setDestination(state2); TransitionImpl endTransition = state2.createOutgoingTransition(); endTransition.setDestination(end); return processDefinition; } private JpdlProcessDefinition loadProcessDefinition() throws IOException { JpdlParser jpdlParser = new JpdlParser(); Parse parse = jpdlParser.createParse(); FileInputStream inputStream = new FileInputStream("process.jpdl.xml"); parse.setInputStream(inputStream); parse.execute(); return (JpdlProcessDefinition) parse.getDocumentObject(); } class HelloActivity implements ExternalActivityBehaviour { public void signal(ActivityExecution activityExecution, String signalName, Map<String, ?> stringMap) throws Exception { activityExecution.take(signalName); } public void execute(ActivityExecution activityExecution) throws Exception { System.out.println("=================Hello there==========="); activityExecution.waitForSignal(); } } }
As you can see it uses the internal API quite a bit.
Mihail -
7. Re: jbpm 4.0 creating and running processes without persiste
kukeltje Jul 25, 2009 11:36 AM (in response to thirumalvishnu)I thought there already was a jira entry for this, but there isn't. A wiki page does exist: http://www.jboss.org/community/wiki/jBPM4ExecutionModes
-
8. Re: jbpm 4.0 creating and running processes without persiste
thirumalvishnu Jul 27, 2009 9:18 AM (in response to thirumalvishnu)Hi,
Thanks mihailrc and kukeltje for the solutions. They almost solved my problem except following one issue .
In the JBPM sample project we pass the variable to the execution time like .Map<String, Object> variables = new HashMap<String, Object>(); ......... ............ ProcessInstance processInstance = process.executionService .startProcessInstanceByKey("flow_name", variables);
Similarly I have to pass variable while creating the process.
Any idea how to achieve this with the given code by mihailrc ? -
9. Re: jbpm 4.0 creating and running processes without persiste
thirumalvishnu Sep 1, 2009 7:53 AM (in response to thirumalvishnu)For the above scenario I tried following
private JpdlProcessDefinition loadProcessDefinition() throws IOException {
JpdlParser jpdlParser = new JpdlParser();
Parse parse = jpdlParser.createParse();
String fileLocation ="*****.jpdl.xml";
FileInputStream inputStream = new FileInputStream(fileLocation);
parse.setInputStream(inputStream);
parse.execute();
return (JpdlProcessDefinition ) parse.getDocumentObject();
}
and from calling section had this blockProcessDefinitionImpl processDefinition = loadProcessDefinition(); ClientProcessInstance ci = processDefinition.createProcessInstance(); ci.createVariable("arg", publishArgs); ci.createVariable("fc", fc); ci.start();
But I get the exception ,
org.jbpm.pvm.internal.wire.WireException: couldn't invoke method execute: couldn't create argument 1: null
at org.jbpm.jpdl.internal.activity.JavaActivity.perform(JavaActivity.java:97)
at org.jbpm.jpdl.internal.activity.JpdlAutomaticActivity.execute(JpdlAutomaticActivity.java:14)
at org.jbpm.pvm.internal.model.op.ExecuteActivity.perform(ExecuteActivity.java:60)
at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperationSync(ExecutionImpl.java:625)
at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperation(ExecutionImpl.java:585)
at org.jbpm.pvm.internal.model.ExecutionImpl.start(ExecutionImpl.java:198)
at com.test.flow.FlowController$1.run(FlowController.java:90)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.lang.Exception: couldn't create argument 1: null
at org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor.getArgs(ObjectDescriptor.java:348)
at org.jbpm.jpdl.internal.activity.JavaActivity.perform(JavaActivity.java:79)
... 7 more
Caused by: java.lang.NullPointerException
at org.jbpm.pvm.internal.script.EnvironmentBindings.getReadContext(EnvironmentBindings.java:61)
at org.jbpm.pvm.internal.script.EnvironmentBindings.containsKey(EnvironmentBindings.java:72)
at javax.script.SimpleScriptContext.getAttribute(SimpleScriptContext.java:143)
at org.jbpm.pvm.internal.script.JuelScriptEngine.toELContext(JuelScriptEngine.java:94)
at org.jbpm.pvm.internal.script.JuelScriptEngine.parse(JuelScriptEngine.java:162)
at org.jbpm.pvm.internal.script.JuelScriptEngine.eval(JuelScriptEngine.java:62)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:84)
at org.jbpm.pvm.internal.script.ScriptManager.evaluate(ScriptManager.java:116)
at org.jbpm.pvm.internal.script.ScriptManager.evaluate(ScriptManager.java:108)
at org.jbpm.pvm.internal.script.ScriptManager.evaluateExpression(ScriptManager.java:80)
at org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor.construct(ObjectDescriptor.java:180)
at org.jbpm.pvm.internal.wire.WireContext.construct(WireContext.java:473)
at org.jbpm.pvm.internal.wire.WireContext.create(WireContext.java:452)
at org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor.getArgs(ObjectDescriptor.java:343)
... 8 more
Any help on how to resolve this .... -
10. Re: jbpm 4.0 creating and running processes without persiste
thirumalvishnu Sep 3, 2009 2:46 AM (in response to thirumalvishnu)Hi ,
Still stuck in this ... any help is appreciated ..
Thanks -
11. Re: jbpm 4.0 creating and running processes without persiste
kukeltje Sep 3, 2009 5:02 AM (in response to thirumalvishnu)Look at the testcases of jBPM4 and the api. There is a method where you pass on variables while starting/creating the processinstance.
-
12. Re: jbpm 4.0 creating and running processes without persiste
kukeltje Sep 3, 2009 5:03 AM (in response to thirumalvishnu)Uhhhmm... it is even in the documentation:
http://docs.jboss.com/jbpm/v4.0/userguide/html_single/#withvariables -
13. Re: jbpm 4.0 creating and running processes without persiste
thirumalvishnu Sep 7, 2009 6:41 AM (in response to thirumalvishnu)Hi ,
Finally got it resolved . Adding the following line before
Environment.pushEnvironment(new BasicEnvironment());
the line
ProcessDefinitionImpl processDefinition = loadProcessDefinition();
solves the issue . Not sure whether this is the perfect solution. But process creation and execution happens without any issue
Thanks
Thirumal