问题描述
我正在将jbpm-console(6.0.0.Final)与自定义工作项处理程序一起使用。我已经在我的jbpm-console WAR中嵌入了一个自定义工作项处理程序JAR,如此处的帖子#7所述:
I'm using jbpm-console (6.0.0.Final) with custom work item handlers. I've embedded a custom work item handlers JAR in my jbpm-console WAR as described in post #7 here:
到目前为止,我已经成功地在jbpm-console中启动了流程定义,并且启动了自定义的WorkItemHandler代码。
This is all fine so far, as I can successful start a process definition in jbpm-console, and it kicks off my custom WorkItemHandler code.
但是,我想在WorkItemHandler中进行设置ProcessInstance上的一些变量。当我尝试类似这样的操作时:
However, in my WorkItemHandler, I want to set some variables on the ProcessInstance. When I try something like this:
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
KieServices ks = KieServices.Factory.get();
KieContainer kContainer = ks.getKieClasspathContainer();
// BLOWS UP HERE
//
KieSession session = kContainer.newKieSession();
WorkflowProcessInstance processInstance =
session.getProcessInstance(workItem.getProcessInstanceId());
// SET VARIABLE
processInstance.setVariable("foo", "bar");
}
它找不到默认的KieSession:
It "Cannot find a default KieSession":
11:21:03,177 ERROR Exception: java.lang.RuntimeException: Cannot find a default KieSession
at org.drools.compiler.kie.builder.impl.KieContainerImpl.findKieSessionModel(KieContainerImpl.java:302) [drools-compiler-6.0.0.Final.jar:6.0.0.Final]
at org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:295) [drools-compiler-6.0.0.Final.jar:6.0.0.Final]
at org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:278) [drools-compiler-6.0.0.Final.jar:6.0.0.Final]
我在这里想念什么?我是否需要设置其他内容?我只是在使用开箱即用(自定义工作项处理程序嵌入式jar除外)从此处安装演示:
What am I missing here? Do I have to set something additional up? I'm just using the out-of-the-box (with the exception of the custom work item handler embedded jar) "demo" install from here:
谢谢!
推荐答案
资源文件夹中是否有kmodule.xml?如果不是这样,那就是问题所在。您可以拥有一个非常简单的xml文件,例如:
Do you have a kmodule.xml in your resources folder? If not maybe that's the problem. You can have a pretty simple xml file like:
<kmodule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://jboss.org/kie/6.0.0/kmodule">
</kmodule>
这篇关于从jbpm6 WorkItemHandler访问KieSession的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!