Drools setup

Before we start

Drools is a Business Rules Management System (BRMS) solution. It provides a core Business Rules Engine (Kie-Server), a web authoring and rules management application (Kie-Workbench) and an Eclipse IDE plugin for core development.

kie-workbench is a UI and allows following

  • Creation of a project/container
  • Creation of rule or guided rule
  • Creation of data objects which are like POJO objects.
  • Deploy created project/container to kie-server.

kie-server is component which

  • Accepts REST requests to manage or execute containers/rules

This document will explain how to setup drools(kie-server and kie-workbench) and how to create rules and container and deploy them onto kie-server and execute rules using REST interface.

 

Setup

Drools can be deployed on any web server either on windows or Linux. This document is going to cover the procedure with a Linux environment with 6.3.0-final version of drools. Windows setup is also similar.

We will need to have tomcat8 and then install kie-server and kie-workbench on this instance of tomcat server.

  1. Download tomcat8 from here and unzip it into a desirable location. Once done set variable TOMCAT_HOME as the path to this extracted folder which contains bin.
  2. Set CATALINA_HOME as TOMCAT_HOME
  3. Download war files for kie-server-6.3.0.Final-webc.war from here and kie-wb-distribution-wars-6.3.0.Final-tomcat7.war from here.
  4. Place the war files in $TOMCAT_HOME/webapps and rename them to kie-server.war and kie-wb.war respectively
  5. Download following jars into $TOMCAT_HOME/lib
    1. btm-2.1.4
    2. btm-tomcat55-lifecycle-2.1.4
    3. h2-1.3.161
    4. jacc-1.0
    5. jta-1.1
    6. kie-tomcat-integration-6.3.0.Final
    7. slf4j-api-1.7.2
    8. slf4j-jdk1
  6. Create bitronix config file $TOMCAT_HOME/conf/btm-config.properties with following content

    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

  7. Create $TOMCAT_HOME/conf/propertieswith following content

    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

  8. Create two users. Kieserver to access kie-server and workbench user to access kie-workbench. Edit $TOMCAT_HOME/conf/tomcat-users.xmland add this content inside <tomcat-users>

    <role rolename=”admin”/>
    <role rolename=”analyst”/>
    <role rolename=”user”/>
    <role rolename=”kie-server”/>
    <user username=”workbench” password=”workbench1!” roles=”admin,kie-server”/>
    <user username=”kieserver” password=”kieserver1!” roles=”kie-server”/>

  9. Create a file $TOMCAT_HOME/bin/setenv.shwith following content

    CATALINA_OPTS=”-Xmx512M -XX:MaxPermSize=512m -Dbtm.root=$CATALINA_HOME -Dorg.jbpm.cdi.bm=java:comp/env/BeanManager -Dbitronix.tm.configuration=$CATALINA_HOME/conf/btm-config.properties -Djbpm.tsr.jndi.lookup=java:comp/env/TransactionSynchronizationRegistry -Djava.security.auth.login.config=$CATALINA_HOME/webapps/kie-wb/WEB-INF/classes/login.co nfig -Dorg.kie.server.persistence.ds=java:comp/env/jdbc/jbpm -Dorg.kie.server.persistence.tm=org.hibernate.service.jta.platform.internal.BitronixJtaPlatform -Dorg.kie.server.id=tomcat-kieserver -Dorg.kie.server.location=http://localhost:8080/kie-server/services/rest/server -Dorg.kie.server.controller=http://localhost:8080/kie-wb/rest/controller”

  10. Startup tomcat server by running following commands

    cd $TOMCAT_HOME/bin
    ./startup.sh

  11. Check for the log file $TOMCAT_HOME/logs/catalina.out to see if there are any errors. Resolve all errors to ensure it is running fine.

 

Verification

  • Use your browser and hit the address <host address>:8080/kie-server/services/rest/server.
  • This should prompt for login credentials. Use kieserver and kieserver1! to login.
  • After successfully logging in a message like below should be obsereved.

    <response type=”SUCCESS” msg=”Kie Server info”>
    <kie-server-info>
    <capabilities>KieServer</capabilities>
    <capabilities>BPM</capabilities>
    <capabilities>BRM</capabilities>
    <location>
    http://localhost:2902/kie-server/services/rest/server
    </location>
    <name>tomcat-kieserver</name>
    <id>tomcat-kieserver</id>
    <version>6.3.0.Final</version>
    </kie-server-info>
    </response>

  • Similarly to verify kie-workbench use this address <host address>:8080/kie-wb
  • This would promt for login credentials. That should open the workbench UI.
  • Navigate to deploy >> rules deployment. In this page a server should be listed already. If not, it indicates that the kie-workbench is not able to talk to kie-server properly.
  • Once above steps are done, we have kie-server and kie-workbench setup properly.