Drools的。无法强制转换为java.lang.Number

时间:2014-02-10 15:48:41

标签: events casting drools drools-fusion

我有这些声明:

 declare Event
     @role(event)
     @timestamp(time)
     //@expires(100ms)
     //params : Map<String, Object> 
     param : long
     time : long    
 end


 declare Expectation
     event: Event
     state: int //-1 pending, 0 violated, 1 fulfilled
 end

 declare ExpectationLeftArmStr extends Expectation
 end

我写过一条规则:

  ExpectationLeftArmStr exp = new ExpectationLeftArmStr();
  exp.setEvent($ev);
  exp.setState(-1);//pending
  insert(exp); 

$ev是我用于规则的正确事件。 错误是:rec.dom.LeftArmStr cannot be cast to java.lang.Number其中LeftArmStr$ev

Exception in thread "main" Exception executing consequence for rule "Operazions on LeftArmStr event    33399" in rec.dom: java.lang.ClassCastException: rec.dom.LeftArmStr cannot be cast to java.lang.Number
    at org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
    at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1297)
    at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221)
    at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456)
    at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
    at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
    at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
    at org.rec.Session.notify(Session.java:136)
    at org.ece.reasoner.ReasonerECE.notifyEvent(ReasonerECE.java:73)
    at org.ece.main.MainLaucher.main(MainLaucher.java:245)
Caused by: java.lang.ClassCastException: rec.dom.LeftArmStr cannot be cast to java.lang.Number
    at org.drools.base.evaluators.BeforeEvaluatorDefinition$BeforeEvaluator.evaluateCachedRight(BeforeEvaluatorDefinition.java:306)
    at org.drools.rule.constraint.EvaluatorConstraint.isAllowedCachedRight(EvaluatorConstraint.java:80)
    at org.drools.common.SingleBetaConstraints.isAllowedCachedRight(SingleBetaConstraints.java:134)
    at org.drools.reteoo.JoinNode.propagateFromRight(JoinNode.java:156)
    at org.drools.reteoo.JoinNode.assertObject(JoinNode.java:148)
    at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
    at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:141)
    at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
    at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
    at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
    at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:350)
    at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:311)
    at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:903)
    at org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:192)
    at org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:186)
    at rec.dom.Rule_Operazions_on_LeftArmStr_event____33399_4678ddba7e884b11b1acf302cef8a05c.defaultConsequence(Rule_Operazions_on_LeftArmStr_event____33399_4678ddba7e884b11b1acf302cef8a05c.java:19)
    at rec.dom.Rule_Operazions_on_LeftArmStr_event____33399_4678ddba7e884b11b1acf302cef8a05cDefaultConsequenceInvokerGenerated.evaluate(Unknown Source)
    at rec.dom.Rule_Operazions_on_LeftArmStr_event____33399_4678ddba7e884b11b1acf302cef8a05cDefaultConsequenceInvoker.evaluate(Unknown Source)
    at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1287)
    ... 8 more

0 个答案:

没有答案