Reputation: 23
According to JBPM's user guide about Fluent API, I try to create a process using Fluent API of drools' 7.62.0 version, and follows is my example code:
public static void testFluentCreateBPMN2() {
String processId = "process1";
ProcessBuilderFactory factory = ProcessBuilderFactories.get();
// Create process builder
Process process = factory.processBuilder(processId)
// package and name
.packageName("org.jbpm")
.name("My process")
// start node
.startNode(1).name("Start").done()
// Add variable of type string
.variable(Variable.var("pepe", String.class))
// Add exception handler
.exceptionHandler(IllegalArgumentException.class, Dialect.JAVA, "System.out.println(\"Exception\");")
// script node in Java language that prints "action"
.actionNode(2).name("Action")
.action(Dialect.JAVA,
"System.out.println(\"Action\");").done()
// end node
.endNode(3).name("End").done()
// connections
.connection(1, 2)
.connection(2, 3)
.build();
KieHelper kieHelper = new KieHelper();
KieSession kieSession = kieHelper.build().newKieSession();
Map<String, Object> maps = new HashMap<>();
maps.put("pepe", "Hello World");
kieSession.startProcess(processId, maps);
}
when I try to execute this code, a error occurs which execute ProcessBuilderFactories.get()
follows:
Exception in thread "main" java.lang.NullPointerException
at org.jbpm.process.core.impl.XmlProcessDumperFactory.newXmlProcessDumperFactory(XmlProcessDumperFactory.java:24)
at org.jbpm.ruleflow.core.RuleFlowProcessFactoryBuilder.<init>(RuleFlowProcessFactoryBuilder.java:26)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at org.kie.api.fluent.ProcessBuilderFactories.get(ProcessBuilderFactories.java:38)
at org.example.App.testFluentCreateBPMN2(App.java:28)
at org.example.App.main(App.java:23)
I feel very puzzled about this problem. And do you can give me it's solution or some advice? Thank you very much.
Upvotes: 1
Views: 201
Reputation: 423
Are you including in your code the dependency to jbpm-bpmn2
or any other implementation of the interface XmlProcessDumperFactoryService
?
jbpm-bpmn2 has this one:
public class XmlProcessDumperFactoryServiceImpl implements XmlProcessDumperFactoryService {
public XmlProcessDumper newXmlProcessDumper() {
return XmlBPMNProcessDumper.INSTANCE;
}
}
Upvotes: 1