cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to connect Activiti with drools

deepakchoudhary
Champ in-the-making
Champ in-the-making
I want to integrate drools rules with activiti and on deploying my .BAR file (which contains .drl file also) I get an error message Deployment xxxx does not contain rules.
I am new to java, activiti and drools.

I have followed the steps on the thread http://forums.activiti.org/content/businessruletask-deploy-error.
therefor I have added these jars to /path/to/webapps/activiti-explorer/WEB-INF/libs/ as well as to the maven dependencies in my project:
drools-api-5.1.1.jar
droools-core-5.1.1.jar
drools-compiler-5.1.1.jar
mvel2-2.1.0.drools.jar


Also I have edited the applicationContext.xml file  in /path/to/webapps/activiti-explorer/

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
   xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jee="http://www.springframework.org/schema/jee"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
       http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd">
      
  <import resource="activiti-standalone-context.xml" />
  <import resource="activiti-ui-context.xml" />
   <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration">
      <property name="databaseSchemaUpdate" value="true" />
      <property name="customPostDeployers">
         <list>
            <bean class="org.activiti.engine.impl.rules.RulesDeployer" />
         </list>
      </property>
   </bean>
</beans>

I have created a simple project using eclipse with a bpmn file and a business rule.
After deploying when I start the process and the user fills the form an error occurs- Deployment xxxx does not contain rules.
The user at the thread I have mentioned above suggested to read chapter 12 of the book- activiti in action, but I could not understand much of it. For eg in which directory should I include the java code, mentioned in the book, with my project.
Any help would be highly appreciated.
20 REPLIES 20

Hi trademak,
I regret for my late reply. I was trying to solve the problem. I did the below thing to start the rules deployer.
I have added new versions of drools libraries and I added
<code>
<property name="customPostDeployers">
         <list>
           <bean class="org.activiti.engine.impl.rules.RulesDeployer" />
         </list>
</property>
</code>
To the activiti-standalone-context.xml and it has started taking rules into consideration. But I am facing an error which I cannot resolve.
The link to my project is  https://github.com/deepakchoudhary/activiti-drools.git

I am trying to deploy the bar file on activiti-explorer and it shows the error Could not initialize class org.drools.RuleBaseConfiguration
I have these versions of drool jars:
drools-compiler-5.5.0.Final.jar
drools-core-5.5.0.Final.jar(I added these versions because lower than 5.4.0 versions java 1.7 was not supported and it showed errors for the same)

catalina log:

Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.drools.RuleBaseConfiguration
at org.drools.common.AbstractRuleBase.<init>(AbstractRuleBase.java:155)
at org.drools.reteoo.ReteooRuleBase.<init>(ReteooRuleBase.java:151)
at org.drools.reteoo.ReteooRuleBase.<init>(ReteooRuleBase.java:128)
at org.drools.RuleBaseFactory.newRuleBase(RuleBaseFactory.java:86)
at org.drools.RuleBaseFactory.newRuleBase(RuleBaseFactory.java:74)
at org.drools.RuleBaseFactory.newRuleBase(RuleBaseFactory.java:37)
at org.drools.impl.KnowledgeBaseFactoryServiceImpl.newKnowledgeBase(KnowledgeBaseFactoryServiceImpl.java:49)
at org.drools.KnowledgeBaseFactory.newKnowledgeBase(KnowledgeBaseFactory.java:63)
at org.drools.builder.impl.KnowledgeBuilderImpl.newKnowledgeBase(KnowledgeBuilderImpl.java:81)
at org.activiti.engine.impl.rules.RulesDeployer.deploy(RulesDeployer.java:62)
at org.activiti.engine.impl.persistence.deploy.DeploymentManager.deploy(DeploymentManager.java:42)
at org.activiti.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:68)
at org.activiti.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:33)
at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:61)
at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
at org.activiti.engine.impl.RepositoryServiceImpl.deploy(RepositoryServiceImpl.java:70)
at org.activiti.engine.impl.repository.DeploymentBuilderImpl.deploy(DeploymentBuilderImpl.java:134)
at org.activiti.explorer.ui.management.deployment.DeploymentUploadReceiver.deployUploadedFile(DeploymentUploadReceiver.java:96)
at org.activiti.explorer.ui.management.deployment.DeploymentUploadReceiver.uploadFinished(DeploymentUploadReceiver.java:71)
at org.activiti.explorer.ui.custom.UploadComponent.uploadFinished(UploadComponent.java:173)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510)
… 30 more


Also I have attached the full catalina log.

trademak
Star Contributor
Star Contributor
Where did you add these Drools libraries? Because this class is part of drools-core-5.5.0.Final.jar

Best regards,

deepakchoudhary
Champ in-the-making
Champ in-the-making
Hi trademak,
Thanks for the fast response
I had the libraries(jars) in tomcat/activiti-explorer/WEB-INF/lib/
(If I remove the jar files from here then it shows a different error)

I tried 5.5.0.FINAL version of drools-compiler, drools-core and knowledge-api (but a dclass not found occured)(The class was present)
Then I tried all three 5.4.0.FINAL, then a different class not found occured(the class was actually not there).
Then I tried all three 5.3.0.FINAL, and this time the BAR file deployed successfully, but the business rule task is always following the default path. I updated a different workflow but the same thing happened and it always follows the default path irrespective of the value I have entered for it in the form.
(Link to Project BAR File: https://github.com/deepakchoudhary/activiti-drools/blob/master/eclipse_project/Calculator/deployment... )

trademak
Star Contributor
Star Contributor
Please make sure that you first test your rule thoroughly in a unit test. Because, again, there's an error in your rule implementation:

11:04:08,920 [http-bio-8080-exec-8] INFO  org.activiti.engine.impl.bpmn.deployer.BpmnDeployer  - Processing resource MyProcess.bpmn20.xml
11:04:08,973 [http-bio-8080-exec-8] INFO  org.activiti.engine.impl.bpmn.deployer.BpmnDeployer  - Processing resource rules.drl
11:04:08,973 [http-bio-8080-exec-8] INFO  org.activiti.engine.impl.rules.RulesDeployer  - Processing resource MyProcess.bpmn20.xml
11:04:08,973 [http-bio-8080-exec-8] INFO  org.activiti.engine.impl.rules.RulesDeployer  - Processing resource rules.drl
11:04:08,995 [http-bio-8080-exec-8] ERROR org.drools.builder.impl.KnowledgeBuilderImpl  - Rule Compilation error : [Rule name='rule1']
org/activiti/demo/rules/Rule_rule1_9252ca46dbfa42829dccfab13db0d3b4.java (9:497) : The method setResult(String) in the type RuleOutput is not applicable for the arguments (int)

The following JARs have to be on the classpath for Drools 5.5.0.Final:

- drools-core-5.5.0.Final.jar
- drools-compiler-5.5.0.Final.jar
- knowledge-api-5.5.0.Final.jar
- knowledge-internal-api-5.5.0.Final.jar
- mvel2-2.1.3.Final.jar
- antlr-3.3.jar
- antlr-runtime-3.3.jar

Best regards,

deepakchoudhary
Champ in-the-making
Champ in-the-making
Thanks Trademak,
I added the jars and a few modifications to the rules file.
Its working fine now. Smiley Happy

Hi Deepak
I have the same problem like your problem
and here is my jar files:
antlr-3.5.jar
antlr-runtime-3.5.jar
drools-compiler-6.0.1.Final.jar
drools-core-6.0.1.Final.jar
knowledge-api-6.0.1.Final.jar
knowledge-internal-api-5.5.0.Final.jar
mvel2-2.1.8.Final.jar

so can you plz tell me where is my problem?

trademak
Star Contributor
Star Contributor
Hi,

I would expect that the knowledge-internal-api JAR version is the same of the knowledge-api JAR version.

Best regards,

nurliyanamuty
Champ in-the-making
Champ in-the-making
Hi, Im new to Activiti and Drools. I have a problem, my .bpmn file cannot be upload to the Activiti explorer. The red warning sign will appear "org/drools/runtime/rule/AgendaFilter".I have followed the thread and put all the dependency. I want to know, what is my problem? Here I uploaded the pom.xml.

This is my rule

package org.activiti.book;
import com.book.activiti.LaptopOrder;

rule “paymentType”
when
  lapOrder : LaptopOrder(paymentMode == “creditCard”)
then
  lapOrder.setAmtToBePaid((lapOrder.getLaptopAmount()*lapOrder.getLaptopQuantity())-((lapOrder.getLaptopAmount()*lapOrder.getLaptopQuantity())*5/100));
end


Thank You


trademak
Star Contributor
Star Contributor
Our unit tests work against 5.5.0.Final so could you give it a try with that version instead?

Best regards,

nurliyanamuty
Champ in-the-making
Champ in-the-making
Hi..Thanks trademak for the response

Sorry for late response. I have use the 5.5.0 Final. I want to integrate drools rules with activiti and on deploying my .BAR file (which contains .drl file also) I get an error message Deployment xxxx does not contain rules.
I have follow all the steps from book Activiti In Action Chapter 12.
I also use the example from ActivitiInAction source code in chapter 12.

But when i try to change the activiti engine configuration in webapps/activiti-explorer/WEBINF/applicationContext.xml with the RulesDeployer, the Tom Cat show the status 404 not found.

I wan to know what is my problem, or is there any step that i miss?

Thank You