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

hushen.savani hushen.savani at elitecore.com
Thu Nov 29 07:37:55 EST 2012


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:
<http://drools.46999.n3.nabble.com/file/n4021008/01_Fact.bmp>     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");endrule "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/TestSnapshotenableBasicAuthentication=trueusername=adminpassword=adminname=drooltest*   
10. 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 implementationSLF4J: 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



--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Guvnor-java-lang-ClassCastException-Lorg-drools-rule-Package-cannot-be-cast-to-org-drools-rule-tp4021008.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20121129/04701d52/attachment-0001.html 


More information about the rules-users mailing list