[rules-users] Drools Integration with Spring

Ketaki.Deshpande at cognizant.com Ketaki.Deshpande at cognizant.com
Thu Jul 7 07:52:46 EDT 2011


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="http://www.springframework.org/schema/beans"

       xmlns:drools="http://drools.org/schema/drools-spring"  

                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"


 
xmlns:context="http://www.springframework.org/schema/context"

                   xmlns:aop="http://www.springframework.org/schema/aop"

 
xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"

 
xsi:schemaLocation="http://www.springframework.org/schema/beans

 
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd

                http://www.springframework.org/schema/context

 
http://www.springframework.org/schema/context/spring-context-2.5.xsd

                http://www.springframework.org/schema/aop

 
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd

                http://www.directwebremoting.org/schema/spring-dwr

 
http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd

                http://drools.org/schema/drools-spring
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-contain
er/drools-spring/src/main/resources/org/drools/container/spring/drools-s
pring-1.0.0.xsd">

 

         <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>

                

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

                

                <drools:kbase id="kbase">

          <drools:resources> 

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

          </drools:resources>

 

    </drools:kbase>

        

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

 

------------------------------------------------------------------------
----------------------------

DroolsDAOImpl.java : 

 

 

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"); 

        droolsDAOImpl.init_drools(); 

  

    }

 

                public void init_drools() throws Exception{

                                

                                

                                try {

                                                

                                

                                    ksession =
kbase.newStatefulKnowledgeSession();

                                    

                                     

 
intermediateData.setNoofPay(noofPaytemp());

 
intermediateData.setRegPay(regpaytemp());

 


 
ksession.insert(intermediateData);

                                                ksession.fireAllRules();

                                                

                                                }              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



This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. 
Any unauthorised review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken in reliance on this e-mail is strictly 
prohibited and may be unlawful.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110707/17655704/attachment.html 


More information about the rules-users mailing list