I suspect the version of drools and guvnor you are using are not identical.
Use of RuleAgent is most certainly not helping. Did you look at the
/droolsjbpm/guvnor/guvnor-examples demonstration using KnowledgeAgent?
On 29 November 2012 12:59, Hushen Savani <hushen.savani(a)elitecore.com>wrote:
*Hi Team, *
* *
* **I'm a newbie to Drools. Please help me here. *
* *
*1. I have created a Package named "org.sample". *
* *
*2. I have created a Model named "TestModel" in the same package. *
* *
*3. I have created a Fact named "Number" in the same Model. *
* *
*4. "Number" fact is as following: *
** **
[image: Fact]****
** **
*5. Then I have created a category named "TestCategory". *
* *
*6. Then created a sample Rule named "ruletest" in that category. *
* *
*7. Rule is created as following:*
** **
*rule "numberone is equal to numbertwo"*
* when*
* n : Number(numberone == numbertwo);*
* then*
* n.setMessage("numberone is equal to numbertwo");*
*end *
* *
*rule "numberone is greater than numbertwo"*
* when*
* n : Number(numberone > numbertwo);*
* then*
* n.setMessage("numberone is greater than
numbertwo");*
*end*
* *
*rule "numberone is less than numbertwo"*
* when*
* n : Number(numberone < numbertwo);*
* then*
* n.setMessage("numberone is less than numbertwo");
*
*end*
* *
* 8. Built the package and created the snapshot. *
* *
*9. Wrote a JAVA POJO client as following: *
* *
*package* org.sample;****
** **
*import* org.drools.RuleBase;****
*import* org.drools.WorkingMemory;****
*import* org.drools.agent.RuleAgent;****
*import* org.drools.definition.type.FactType;****
** **
*public* *class* DroolGuvnor {****
*public* *static* *void* main(String[] args) *throws*InstantiationException,
IllegalAccessException {
****
RuleAgent ruleAgent = RuleAgent.*newRuleAgent*(
"/Guvnor.properties");****
RuleBase ruleBase = ruleAgent.getRuleBase();****
****
FactType factType = ruleBase.getFactType("org.sample.Number");
****
Object obj = factType.newInstance();****
****
factType.set(obj, "numberone", 2);****
factType.set(obj, "numbertwo", 1);****
****
WorkingMemory workingMemory = ruleBase.newStatefulSession();**
**
workingMemory.insert(obj);****
workingMemory.fireAllRules();****
****
System.*out*.println(factType.get(obj, "message"));****
}****
}****
* *
* *
* 10. The "guvnor.properties" file is as following: *
* *
url=
http://localhost:10080/guvnor-5.5.0.Final-tomcat-6.0/org.drools.guvnor.Gu...
****
enableBasicAuthentication=true****
username=*admin*****
password=*admin*****
name=*drooltest***
* *
* 11. But, when I run the client, I get following exception: *
* *
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".****
SLF4J: Defaulting to no-operation (NOP) logger implementation****
SLF4J: See
http://www.slf4j.org/codes.html#StaticLoggerBinder for further
details.****
Exception in thread "main" *java.lang.ClassCastException*:
[Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package****
at org.drools.agent.HttpClientImpl.fetchPackage(*
HttpClientImpl.java:86*)****
at org.drools.agent.URLScanner.readPackage(*URLScanner.java:171*)***
*
at org.drools.agent.URLScanner.getChangeSet(*URLScanner.java:143*)**
**
at org.drools.agent.URLScanner.loadPackageChanges(*
URLScanner.java:119*)****
at org.drools.agent.RuleAgent.checkForChanges(*RuleAgent.java:431*)*
***
at org.drools.agent.RuleAgent.refreshRuleBase(*RuleAgent.java:383*)*
***
at org.drools.agent.RuleAgent.configure(*RuleAgent.java:368*)****
at org.drools.agent.RuleAgent.init(*RuleAgent.java:268*)****
at org.drools.agent.RuleAgent.newRuleAgent(*RuleAgent.java:208*)****
at org.drools.agent.RuleAgent.newRuleAgent(*RuleAgent.java:168*)****
at org.drools.agent.RuleAgent.newRuleAgent(*RuleAgent.java:277*)****
at org.sample.DroolGuvnor.main(*DroolGuvnor.java:10*)****
** **
*Please help on this. Thanks. *
* *
* *
*Best Regards, *
*Hushen Savani*
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users