加载全局事件监听器JBPM

时间:2018-10-19 22:30:47

标签: java wildfly jbpm kie

我有jbpm系统(wildfly + kie-server + workbench),我想在系统中使用一个全局ProcessEventListener。我创建了一个简单的流程事件lestener:

public class SimpleProcessEventListener implements ProcessEventListener {

    public void beforeNodeTriggered(ProcessNodeTriggeredEvent event) {
        System.out.println("Before Node triggered: " + event.getNodeInstance().getNodeName());
    }

    ...

    public void afterVariableChanged(ProcessVariableChangedEvent event) {
        System.out.println("After Variable changed: " + event.getVariableId());
    }

我的pom.xml:

<modelVersion>4.0.0</modelVersion>
    <groupId>org.example</groupId>
    <artifactId>simple-process-event-listener</artifactId>
    <version>1.0</version>

    <dependencies>
        <dependency>
            <groupId>org.jbpm</groupId>
            <artifactId>jbpm-flow</artifactId>
            <version>6.5.0.Final</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

当我将其添加为部署依赖项并通过工作台在我的jbpm项目中将其声明为事件侦听器时,一切正常。

但是现在我有很多项目,将事件侦听器附加到每个项目上很不舒服。因此,我在wildfly中创建了新模块:

<module xmlns="urn:jboss:module:1.1" name="com.listener">

    <resources>
        <resource-root path="simple-process-event-listener-1.0.jar"/>
    </resources>

    <dependencies>
        <module name="javax.api"/>
        <module name="org.slf4j"/>
    </dependencies>
</module>

已创建Deployment-descriptor.xml服务器级别:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<deployment-descriptor xsi:schemaLocation="http://www.jboss.org/jbpm/deployment-descriptor.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <persistence-unit>org.jbpm.domain</persistence-unit>
    <audit-persistence-unit>org.jbpm.domain</audit-persistence-unit>
    <audit-mode>JPA</audit-mode>
    <persistence-mode>JPA</persistence-mode>
    <runtime-strategy>SINGLETON</runtime-strategy>
    <marshalling-strategies/>
    <event-listeners>
        <event-listener>
            <resolver>reflection</resolver>
            <identifier>org.example.SimpleProcessEventListener</identifier>
            <parameters/>
        </event-listener>
    </event-listeners>
    <task-event-listeners/>
    <globals/>
    <work-item-handlers/>
    <environment-entries/>
    <configurations/>
    <required-roles/>
    <remoteable-classes/>
    <limit-serialization-classes>true</limit-serialization-classes>
</deployment-descriptor>

因此,当我创建一个新的jbpm进程并通过工作台将其部署到kie-server上时,我得到了:

  

由于:java.lang.NoClassDefFoundError:链接失败   org / example / SimpleProcessEventListener(来自以下模块的“ com.listener”   本地模块加载程序@ 3c19aaa5(查找程序:本地模块查找程序@ 3349e9bb   (根:   / opt / jboss / wildfly / modules,/ opt / jboss / wildfly / modules / system / layers / base))):   org / kie / api / event / process / ProcessEventListener

因此,很明显,它试图使用我的侦听器,但找不到由我的侦听器实现的org.kie.api.event.process.ProcessEventListener
所以我该怎么做?为什么不加载?它属于kie-internal-api。而且我在maven依赖项中有jbpm-flow,提供了“范围”。
 在我的所有jbpm进程中使用一个侦听器是正确的方法吗?

2 个答案:

答案 0 :(得分:1)

在WEB-INF / lib中添加simple-process-event-listener-1.0.jar,不要在'com.listener'模块上添加war文件依赖性

答案 1 :(得分:0)

在pathwildfly- \ modules \ system \ layers \ base下添加process-event-listener.jar文件,以进行反映