从jbpm6 WorkItemHandler访问KieSession [英] Accessing KieSession from jbpm6 WorkItemHandler

查看:103
本文介绍了从jbpm6 WorkItemHandler访问KieSession的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将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:

https://community.jboss.org/thread/221748

到目前为止,我已经成功地在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:

http://sourceforge.net/projects/jbpm/files/jBPM %206 / jbpm-6.0.0.Final

谢谢!

推荐答案

资源文件夹中是否有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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆