-
1. Re: Problem with RuleFlowNodeContainerFactory.splitNode(...) method
krisverlaenen Sep 1, 2014 3:09 AM (in response to sanbhat)You need to compile your process if you are using scripts or constraints etc. in your process (this will replace the simple text constraint with a compiled version). Take a look at:
-
2. Re: Re: Problem with RuleFlowNodeContainerFactory.splitNode(...) method
sanbhat Sep 2, 2014 4:47 AM (in response to krisverlaenen)Hi Kris,
Thanks for your answer. I tried your code and now I am getting following error
java.lang.ClassCastException: org.jbpm.workflow.core.DroolsAction cannot be cast to org.jbpm.workflow.core.impl.DroolsConsequenceAction
at org.jbpm.bpmn2.xml.XmlBPMNProcessDumper.visitEscalations(XmlBPMNProcessDumper.java:553)
at org.jbpm.bpmn2.xml.XmlBPMNProcessDumper.visitProcess(XmlBPMNProcessDumper.java:149)
at org.jbpm.bpmn2.xml.XmlBPMNProcessDumper.dump(XmlBPMNProcessDumper.java:104)
at org.jbpm.bpmn2.xml.XmlBPMNProcessDumper.dump(XmlBPMNProcessDumper.java:95)
at com.test.JbpmHelper.createAndRunWorkflow(JbpmHelper.java:49)
Here's the code I am using to create dynamic service tasks (here Action class implementations, mock the service task of the workflow)
String pId = "com.test.process1";
RuleFlowProcessFactory factory = RuleFlowProcessFactory.createProcess(pId);
RuleFlowNodeContainerFactory rfncf = factory.name("test").version("1.0").packageName("com.test");
//Code for service task
rfncf = rfncf.actionNode(1).name("action_task")
.action(new Action() {
public void execute(ProcessContext context) throws Exception {
System.out.println("action executed!!!");
}
})
.done();
...
//Code for split task
...
factory.splitNode(...);
krisverlaenen , I see that there is also an open bug regarding this issue [JBPM-4378] ClassCastException when dumping process with an action node - JBoss Issue Tracker. Can you please tell if there is any fix available / alternate path ?
-
3. Re: Problem with RuleFlowNodeContainerFactory.splitNode(...) method
sanbhat Sep 3, 2014 5:16 AM (in response to krisverlaenen)Digging google led me to the JIRA [JBPM-3428] JBPM5, Split node on XOR, OR using Drools DSL (aka RuleFlowProcessFactory) doesn't seem to work - JBoss Issu... Here the bug reporter has stated a scenario of using both Action interface and Split node in a programmatically created workflow. I am having a requirement with exactly same scenario.
Comments in the bug and the testcases attached, reveals that the reporter is finally omitting the Action interface. Is the fix which is talked about in the bug (on ActionNodeBuilder ) is in progress / available in any release? It would be great if you can please point me to any direction.
-
4. Re: Re: Problem with RuleFlowNodeContainerFactory.splitNode(...) method
krisverlaenen Sep 4, 2014 9:14 AM (in response to sanbhat)1 of 1 people found this helpfulAs shown in the example I linked (jbpm/ProcessFactoryTest.java at master · droolsjbpm/jbpm · GitHub), you shouldn't write your own action implementations, but use the String-based operation (for example action("java", "System.out.println(\"Action\");")). When using the Xml Dumper, we cannot serialize a custom implementation of the Action interface to XML.
-
5. Re: Problem with RuleFlowNodeContainerFactory.splitNode(...) method
sanbhat Sep 5, 2014 2:10 AM (in response to krisverlaenen)Thanks again for your response. Then what if I want to maintain a class for implementation associated with a node (like service task)? What approach should I take here?
Writing java code as string brings difficulty in maintaining the application, as more and more code gets added to the action node. And the code also looks unreadable and very difficult to debug (Example: "System.out.println(\"Action\");"). With class, we can have OOP approach and maintenance,debugging becomes very easy.
-
6. Re: Problem with RuleFlowNodeContainerFactory.splitNode(...) method
krisverlaenen Sep 5, 2014 6:36 AM (in response to sanbhat)Scripts or constraints are embedded in the process and are meant to be small and not too complex. More complex code should indeed be abstracted into separate classes. For example, the service task allows you to define your own custom tasks where you can write a custom handler (Java code implementing the WorkItemHandler interface) to contain the logic for how to do the actual work. Similarly, you can also write for example helper classes and use those in your script, so if System.out.println("...") is too complex, consider using MyHelper.write("...");