0

I have created a Dynamic web project which also uses drools for providing some functionality. When i put the WAR file in Tomcat7 and the server, the drools part does not work.

KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

After this line which is first line relating to drools, nothing happens.

Is some configuration required to run my project containing drools 5.5.0 Final in the Tomcat7.

Please help me. I am badly stuck and I am new to drools.

kaskelotti
  • 4,709
  • 9
  • 45
  • 72
  • Is it just failing silently? Exception eaten perhaps? Can you add a bit more of your code on the part where you fire the rules? – kaskelotti Sep 19 '13 at 14:40

3 Answers3

0

You'll have to add some facts to the working memory and execute(fire) the rules. Check out these examples on GitHub

P.S. Probably not related to Tomcat in any way. Might be worth while to try getting the rules executed from command line app first.

kaskelotti
  • 4,709
  • 9
  • 45
  • 72
  • I have added the facts inside the working memory and also tested my rules in a standalone java application. They are working. – user2763774 Sep 19 '13 at 03:45
  • Whenever the control comes to the function containing the drools API, it skips it and the next process starts. In drools first step is to create knowledge builder. So even if anything is wrong with the rules this line should get executed. I have also put a LOG after this line but the log is never registered. I need to resolve it today. Can you please help me on this. – user2763774 Sep 19 '13 at 03:50
0

You need to check all the dependencies that are added to your web application (WEB-INF/lib) make sure that drools has all the required deps there, because if not it will not be able to create the knowledge builder. Most of the time if it is failing is because that you forgot to add the deps in the web app.

salaboy
  • 4,123
  • 1
  • 14
  • 15
  • I created a dynamic web project with drools part and the required jar files and executed its war file in the Tomcat. It executed perfectly. But when I integrate it with my project then the problem is coming. I am using all the jars that are required. Actually the function that contains drools is called buy run() method of a thread. Can Threading be issue ?? – user2763774 Sep 20 '13 at 11:01
0

The following project in GitHub is a web application, containing some REST-style endpoints for validating IBANs. It uses Drools 5.5 to perform that evaluation.

https://github.com/gratiartis/sctrcd-payment-validation-web/

It generates a .war which can be loaded into Tomcat, and could be a useful starting point. The knowledge base is wrapped within a Spring service:

https://github.com/gratiartis/sctrcd-payment-validation-web/blob/master/src/main/java/com/sctrcd/payments/validation/RuleBasedIbanValidator.java

Following through how that creates a knowledge base and session might help you see where your code is going wrong.

As a bonus, you can run it up in Tomcat using "mvn tomcat7:run" to test it out immediately.

Steve
  • 9,270
  • 5
  • 47
  • 61