[rules-users] Drools Guvnor: java.lang.ClassCastException: [Lorg.drools.rule.Package; cannot be cast to org.drools.rule.Package

Michael Anstis michael.anstis at gmail.com
Thu Nov 29 09:32:21 EST 2012


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 at 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.Guvnor/package/org.sample/TestSnapshot
> ****
>
> 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 at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20121129/ab194e54/attachment-0001.html 


More information about the rules-users mailing list