在本机使用 Tomcat 启动 Drools Workbench,通常情况下直接使用 Docker 起就行了,但是为了学习 KIE Drools Workbench,这边就补习一下 Tomcat 启动方式。

基本的准备工作包括:

  • JDK, JAVA_HOME
  • Tomcat
  • Drools 相关工具
  • sudo 使用权限

installation

Make sure you have Tomcat installed.

Follow this link to download the drools workbench. And choose the Tomcat version to download.

You will get kie-drools-wb-7.11.0.Final-tomcat8.war file. And you can just rename it to kie-wb.war .

And copy(deploy) the .war to TOMCAT/webapps directory.

dependency jars

Download following related jars and copy them to TOMCAT/lib:

  • btm-2.1.4.jar
  • btm-tomcat55-lifecycle-2.1.4.jar
  • h2-1.4.193.jar
  • jta-1.1.jar
  • slf4j-api-1.7.2.jar
  • slf4j-jdk14-1.7.2.jar
  • kie-tomcat-integration-7.11.0.Final.jar kie-tomcat-integration
  • javax.security.jacc-api-1.6.jar JACC (javax.security.jacc:artifactId=javax.security.jacc-api)

These jars can be found at https://mvnrepository.com/

conf

Firstly, modify the vim tomcat\conf\tomcat_user.xml file, and add following between <tomcat-users></tomcat-users>. This file control the privilege of tomcat which is used by KIE:

<role rolename="admin"/>
<role rolename="analyst"/>
<role rolename="user"/>
<role rolename="kie-server"/>
<role rolename="manager"/>
<role rolename="manager-gui"/>
<role rolename="manager-status"/>
<user username="workbench" password="workbench" roles="admin,kie-server"/>
<user username="kieserver" password="kieserver" roles="kie-server"/>
<user username="admin" password="admin" roles="admin,manager-gui,manager-status,manager"/>

Note, analyst or admin roles is required to be authorized to use kie-wb.

Secondly, create setenv.sh (or setenv.bat) under tomcat/bin/

TOMCAT_HOME="/opt/tomcat/"
DATA_PATH="/home/einverne/data/kie-wb"
CATALINA_OPTS="-Xmx512M  \
            -XX:MaxPermSize=512m  \
            -Dbtm.root=$TOMCAT_HOME \
            -Dbitronix.tm.configuration=$TOMCAT_HOME\conf\btm-config.properties \
            -Djbpm.tsr.jndi.lookup=java:comp/env/TransactionSynchronizationRegistry \
            -Djava.security.auth.login.config=$TOMCAT_HOME\webapps\kie-drools-wb\WEB-INF\classes\login.config \
            -Dorg.jboss.logging.provider=jdk \
            -Dorg.uberfire.nio.git.dir=$DATA_PATH \
            -Dorg.uberfire.nio.git.ssh.cert.dir=$DATA_PATH \
            -Dorg.guvnor.m2repo.dir=$DATA_PATH/repo \
            -Dorg.uberfire.metadata.index.dir=$DATA_PATH"

NOTE: On Debian based systems $CATALINA_HOME needs to be replaced with $CATALINA_BASE. ($CATALINA_HOME defaults to /usr/share/tomcat8 and $CATALINA_BASE defaults to /var/lib/tomcat8/)

NOTE: this is an example for unix like systems for Windows $CATALINA_HOME needs to be replaced with windows env variable or absolute path

NOTE: java.security.auth.login.config value includes name of the folder in which application is deployed by default it assumes kie-drools-wb so ensure that matches real installation. login.config file can be externalized as well meaning be placed outside of war file.

Then add valve configuration into TOMCAT_HOME/conf/server.xml inside Host element as last valve definition:

<Valve className="org.kie.integration.tomcat.JACCValve" />

Create btm-config.properties file under tomcat/conf and add this:

bitronix.tm.serverId=tomcat-btm-node0
bitronix.tm.journal.disk.logPart1Filename=%{btm.root}%\work\btm1.tlog
bitronix.tm.journal.disk.logPart2Filename=%{btm.root}%\work\btm2.tlog
bitronix.tm.resource.configuration=%{btm.root}%\conf\resources.properties

Create resources.properties file under tomcat/conf:

resource.ds1.className=bitronix.tm.resource.jdbc.lrc.LrcXADataSource
resource.ds1.uniqueName=jdbc/jbpm
resource.ds1.minPoolSize=10
resource.ds1.maxPoolSize=20
resource.ds1.driverProperties.driverClassName=org.h2.Driver
resource.ds1.driverProperties.url=jdbc:h2:mem:jbpm
resource.ds1.driverProperties.user=sa
resource.ds1.driverProperties.password=
resource.ds1.allowLocalTransactions=true

打开 KIE

打开 http://localhost:8080 端口应该能看到 Tomcat 页面,在 Tomcat 管理 app 页面中 (http://localhost:8080/manager/html) 启动 KIE

在列表中会看到 kie-wb 这个项目,初始状态应该是 stop 状态,点击启动,观察 Tomcat 下 logs/catalina.out 应该能够看到启动日志,如果出现错误,需要处理一下。通常情况下可能会出现创建目录失败的问题,手动创建目录并给予写入权限即可。

等待启动后,点击左边的 path 进入应用,使用 Tomcat 中配置的权限登录。

reference