Hi For this I saved the schema (change-set-1.0.0.xsd) on my local machine and gave the path in the ChangeSet.xml
Now its working fine... Regards, Sumeet Karawal Mailto: sumeet.kara...@tcs.com ----- Forwarded by Sumeet Karawal/MUM/TCS on 08/22/2011 03:44 PM ----- From: Sumeet Karawal <sumeet.kara...@tcs.com> To: rules-users@lists.jboss.org Date: 08/18/2011 06:24 PM Subject: [rules-users] Guvnor Sample Rule Sent by: rules-users-boun...@lists.jboss.org Hi, I am trying to create rule in Guvnor and runnig it in Java Application on Eclipse. I have gone through the mortgages example provided in the distribution. I am not sure that I am doing it correctly The steps I did are as follows : 1) Uploaded a POJO jar in Guvnor 2) Created a rule for checking the value of POJO data member 3) Built the package 4) Downloaded the ChangeSet.xml provided 5) Imported that ChangeSet.xml in Eclipse project under com.test package. 6) Created KnowledgeBase and fired the rules My POJO : package com.test; public class CardHolder { private int accno; private double discount; public int getAccno() { return accno; } public void setAccno(int accno) { this.accno = accno; } public double getDiscount() { return discount; } public void setDiscount(double discount) { this.discount = discount; } } My Rule Running Class : package com.test; import org.drools.KnowledgeBase; import org.drools.agent.KnowledgeAgent; import org.drools.agent.KnowledgeAgentFactory; import org.drools.io.Resource; import org.drools.io.ResourceFactory; import org.drools.runtime.StatefulKnowledgeSession; public class Discount_Provider { public static void main(String[] args) { CardHolder c1 = new CardHolder(); c1.setAccno(1005); try{ KnowledgeBase kbase = readKnowledgeBase(); StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); ksession.insert(c1); ksession.fireAllRules(); System.out.println("The discount applied is : "+ c1.getDiscount()); } catch (Exception ex) { System.out.println("Exception is : "+ex); } } private static KnowledgeBase readKnowledgeBase() { KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent ("DiscAgent"); Resource changeset = ResourceFactory.newClassPathResource ("com/test/ChangeSet.xml"); kagent.applyChangeSet(changeset); KnowledgeBase kbase = kagent.getKnowledgeBase(); kagent.dispose(); return kbase; } } My Rule Content : 1.|rule "Discount_CardHolder" 2.| dialect "mvel" 3.| when 4.| $c : CardHolder( accno > 1001 ) 5.| then 6.| $c.setDiscount( 10 ); 7.| update( $c ); 8.|end Link from where I download the ChangeSet from Guvnor : Change Set: |--------------------------------------------------------------------------------------------------------------------------------------------> | http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/TestPackage/LATEST/ChangeSet.xml | |--------------------------------------------------------------------------------------------------------------------------------------------> >-------------| |(Embedded | |image moved | |to file: | |pic19477.gif)| >-------------| Contents of ChangeSet.xml : <change-set xmlns='http://drools.org/drools-5.0/change-set' xmlns:xs='http://www.w3.org/2001/XMLSchema-instance' xs:schemaLocation='http://drools.org/drools-5.0/change-set http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd' > <add> <resource source='http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/TestPackage/LATEST' type='PKG' /> </add> </change-set> Errors that I get : (null: 3, 175): schema_reference.4: Failed to read schema document 'http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>. (null: 3, 175): cvc-elt.1: Cannot find the declaration of element 'change-set'. (null: 4, 10): schema_reference.4: Failed to read schema document 'http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>. (null: 5, 130): schema_reference.4: Failed to read schema document 'http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>. The discount applied is : 0.0 I am not able to get what should be done to make it run properly. Earlier also I had tried to do this but faced many issues. By referring the Mortgages example I tried to create the calling class. It would be very helpful if some body could help me on this. Thanks & Regards, Sumeet Mailto: sumeet.kara...@tcs.com =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you [attachment "pic19477.gif" deleted by Sumeet Karawal/MUM/TCS] _______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users _______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users