我是JBPM的新人。
我创建了带有start,diverge和两个脚本以及融合和结束任务的bpmn文件。
我的代码是
package com.sample;
import java.util.HashMap;
import java.util.Map;
import org.drools.KnowledgeBase;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.process.ProcessInstance;
public class ProcessTest {
public static void main(String[] args){
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newClassPathResource("sample.bpmn"),
ResourceType.BPMN2 );
KnowledgeBase kbase = kbuilder.newKnowledgeBase();
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
Map<String,Object> params=new HashMap<String,Object>();
params.put("income", 1200);
ProcessInstance processInstance = ksession.startProcess("com.sample.bpmn.hello",params);
}
}
但是我收到以下错误
org.drools.RuntimeDroolsException: invalid package name
at org.jbpm.compiler.ProcessBuilderImpl.buildProcess(ProcessBuilderImpl.java:175)
at org.jbpm.compiler.ProcessBuilderImpl.addProcessFromXml(ProcessBuilderImpl.java:254)
at org.drools.compiler.PackageBuilder.addProcessFromXml(PackageBuilder.java:564)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:608)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:37)
at com.sample.ProcessTest.main(ProcessTest.java:23)
[6,13]: [ERR 102] Line 6:13 mismatched input 'income' in rule "RuleFlow- Split-com.sample.bpmn.hello-2-3-DROOLS_DEFAULT"
[13,13]: [ERR 102] Line 13:13 mismatched input 'income' in rule "RuleFlow- Split-com.sample.bpmn.hello-2-4-DROOLS_DEFAULT"
[0,0]: Parser returned a null Package
ProcessLoadError: unable to parse xml : Exception class org.drools.RuntimeDroolsException : invalid package name
Exception in thread "main" java.lang.IllegalArgumentException: Could not parse knowledge.
at org.drools.builder.impl.KnowledgeBuilderImpl.newKnowledgeBase(KnowledgeBuilde rImpl.java:67)
at com.sample.ProcessTest.main(ProcessTest.java:26)
我在sample.bpmn
中给出了包名com.sample我的sample.bpmn文件是