Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Al Hobbs
  • salvin francis

Spring Integration with Drools

Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Experts,

I am facing one issue while integrating drools with Spring.

I have done the following configurations

Beans.xml :

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""

<bean id="droolsDAOImpl" class="com.dao.DroolsDAOImpl">
<property name="sessionFactory" ref="mySessionFactory" />
<property name="ksession" ref="ksession" />
<property name="intermediateData" ref="intermediateData" />
<property name="kbase" ref="kbase" />

<bean id="intermediateData" class="com.pojo.IntermediateData" />

<drools:kbase id="kbase">
<drools:resource type="DRL" source="classpath:Sample.drl"></drools:resource>


<drools:ksession id="ksession" type="stateful" kbase="kbase"/>

---------------------------------------------------------------------------------------------------- :

public class DroolsDAOImpl implements DroolsDAO {

private StatefulKnowledgeSession ksession;

private IntermediateData intermediateData;

private KnowledgeBase kbase;

public KnowledgeBase getKbase() {
return kbase;

public void setKbase(KnowledgeBase kbase) {
this.kbase = kbase;

public StatefulKnowledgeSession getKsession() {
return ksession;

public void setKsession(StatefulKnowledgeSession ksession) {
this.ksession = ksession;

public static void main(String args[]) throws Exception{

Resource res = new ClassPathResource("beans.xml");
BeanFactory factory = new XmlBeanFactory(res);
DroolsDAOImpl droolsDAOImpl=(DroolsDAOImpl)factory.getBean("droolsDAOImpl");


public void init_drools() throws Exception{

try {

ksession = kbase.newStatefulKnowledgeSession();



} catch (Throwable t) {

logger.error("Exception occured in DroolsDAOImpl---"+t);
throw new Exception("Some Error Occured. Please try after some time");

} }

I am having one drl file : Sample.drl which contains rule and IntermediateData is simple pojo.
But after running this I am getting following error:

Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'drools:kbase'.

Can anyone help me with this issue? Thanks in advance
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you solve the issue?

If not, try to download the jar drools-spring-[drools version].jar there you'll find the .xsd files for "drools-spring", extract the "drools-spring-1.2.0.xsd" and place it in your project's classpath, after that you can replace: http://anonsvn.jboss....spring/drools-spring-1.0.0.xsd

with this: file:///path_to_the_xsd_file_in_your_project/drools-spring-1.2.0.xsd

If the error changes to:

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace []

if you didn't add the drools-spring.jar to your project's classpath then you should do it. Note that drools-spring.jar is not included in the Drools binaries, at least it doesn't in the distribution I've downloaded (5.2.0.Final), but you can download it from a Maven repository or if you are using Maven you can add the dependency:

This has solved the problem in my case. Hope it helps...
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic