[rules-users] Fusion [Error]- java.lang.ClassCastException: org.drools.common.DefaultFactHandle cannot be cast to org.drools.common.EventFactHandle
Chetan Mahadev
mahadev.chetan at gmail.com
Tue Nov 10 04:38:13 EST 2009
Hi Edson, Salaboy,
Just to explain what I meant in my previous mail... This is wat we are
doin...
We are inserting a EligibleAlert in one of the rules like this.This is a
seperate drl file.. I tried declaring EligibleAlert as an event in this
.drl file.
rule "process pending sympathetic alert"
agenda-group "AlertProcessing"
auto-focus true
no-loop
salience 50
when
ProcessedAlert ( rootCause == true,
$alarmId : alarmIdentifier,
ticketed == true,
$custId: companyId );
$pendingAlert : PendingAlert ( rootCause == false,
rootCauseId == $alarmId,
companyId == $custId );
then
Alert $alert = $pendingAlert.getAlert();
try {
insert ( new EligibleAlert($alert) );
} catch (Throwable e) {
insert(new RuleProcessingError("[processing] process
pending sympathetic alert", $alert, e));
log.error("[processing] ERROR - process pending
sympathetic alert [alert=" + $alert.getId() + "][error=" + e.toString() +
"]");
}
end
Drl file 2:
-----------------------------------------------------
declare EligibleAlert
@role( event )
end
rule "Check if EligibleAlert is an Signature Event"
agenda-group "enrichment"
auto-focus true
//salience 100
no-loop true
when
$list : EventSignatureList();
$p : EligibleAlert($a : alert,
$a.eventSignatureProcessingStatus!="TRUE" );
eval((ifMatchesSyslog($list.getAllSyslogMnemonics(), $a)!=null) )
then
try{
WorkingMemoryEntryPoint eventsignaturestream
= drools.getEntryPoint("EVENT SIGNATURE STREAM") ;
eventsignaturestream.insert($p);
} catch(Exception e)
{
log.error("[EventSignatureRules] - exception in
Check if EligibleAlert is an Signature Event alert[ids=" +
$p.getAlert().getId() + "][error:" + e.toString() + "]");
}
end
rule "testRule"
agenda-group "enrichment"
salience 105
auto-focus true
no-loop true
when
$e1:EligibleAlert($a1 : alert
) from entry-point "EVENT SIGNATURE STREAM"
$e2:EligibleAlert($a2 : alert,
this after[0, 20s] $e1
) from entry-point "EVENT SIGNATURE STREAM"
not(EligibleAlert(
this after $e1,
this before $e2
) from entry-point "EVENT SIGNATURE STREAM")
then
log.debug("[EventSignature]*******RULE: TEST" );
log.debug("[EventSignature]------------------------------------------------------------------------------------"
);
log.debug("[EventSignature] ALERT :
"+$e1.getAlert().getAlternateAlertText());
log.debug("[EventSignature] COMMONINFO : "
+$e1.getAlert().getCommonInfo());
log.debug("[EventSignature] ALERT :
"+$e2.getAlert().getAlternateAlertText());
log.debug("[EventSignature] COMMONINFO : "
+$e2.getAlert().getCommonInfo());
log.debug("[EventSignature]------------------------------------------------------------------------------------"
);
end
Hope this helps in correcting my mistake anywhere.....
Regds
Chetan
On Tue, Nov 10, 2009 at 7:58 AM, Chetan Mahadev <mahadev.chetan at gmail.com>wrote:
> We have few .drl files where we are inserting EligibleAlert into working
> memory. Should we declare with @role(event) in all the files or only once
> anywhere??
>
> Currently I have declared it as an @role(event) in the current drools file
> where I am applying
> temporal reasoning. Is tht only sufficient.. ? or in all.drl files?
>
> Or in the .drl file, where for the first time it is being inserted into
> WM?? I am clueless..
>
>
>
> 2009/11/10 Edson Tirelli <ed.tirelli at gmail.com>
>
>
>> Assuming this is the offending rule, for some reason, Drools is not
>> interpreting EligibleAlert as an "event". You need to double check your code
>> to make sure it is declared with @role( event ) as previously mentioned by
>> Mauricio.
>>
>>
>> []s
>> Edson
>>
>> 2009/11/9 Chetan Mahadev <mahadev.chetan at gmail.com>
>>
>>> Etirelli,
>>>
>>> So u mean to say, some other rule is causing the problem?
>>>
>>> I have this rule which uses events from entry-point after it is being
>>> inserted in my earlier rule..
>>>
>>> rule "testRule"
>>> no-loop true
>>> when
>>>
>>> $eventSignature : EventSignature($list : syslogmnemonicList,
>>> totalevents == "2")
>>> $e1:EligibleAlert($a1 : alert,
>>> eval(ifMatches($list,$a1))
>>> ) from entry-point "EVENT SIGNATURE STREAM"
>>>
>>> $e2:EligibleAlert($a2 : alert,
>>> // $a2.processed!="TRUE",
>>> // $a1.customerId==$a2.customerId,
>>> //($a1.alternateAlertText!= $a2.alternateAlertText) ,
>>> eval(ifMatches($list,$a1)),
>>> eval(ifMatches($list,$a2)),
>>> this after[0, 20s] $e1
>>> ) from entry-point "EVENT SIGNATURE STREAM"
>>>
>>>
>>>
>>> not(EligibleAlert(
>>> this after $e1,
>>> this before $e2
>>> ) from entry-point "EVENT SIGNATURE STREAM")
>>>
>>> then
>>> log.debug("[EventSignature]*******RULE: TEST" );
>>>
>>> log.debug("[EventSignature]------------------------------------------------------------------------------------"
>>> );
>>> log.debug("[EventSignature] STATUS : "+$list);
>>> log.debug("[EventSignature] ALERT :
>>> "+$e1.getAlert().getAlternateAlertText());
>>> log.debug("[EventSignature] COMMONINFO : "
>>> +$e1.getAlert().getCommonInfo());
>>>
>>>
>>> log.debug("[EventSignature] ALERT :
>>> "+$e2.getAlert().getAlternateAlertText());
>>> log.debug("[EventSignature] COMMONINFO : "
>>> +$e2.getAlert().getCommonInfo());
>>> log.debug("[EventSignature] SIGNATURE :
>>> "+$eventSignature.getEventsignature());
>>>
>>> log.debug("[EventSignature]------------------------------------------------------------------------------------"
>>> );
>>>
>>>
>>> end
>>>
>>> Where do you see the problem?? Pls help...
>>>
>>> 2009/11/9 Edson Tirelli <ed.tirelli at gmail.com>
>>>
>>>
>>>> The stack trace shows the problem is happening in a use of the
>>>> "after" evaluator:
>>>>
>>>>
>>>> 2009-11-09 15:02:00,676 FATAL pool-2-thread-1 LogStream - at
>>>> org.drools.base.evaluators.AfterEvaluatorDefinition$AfterEvaluator.evaluateCachedRight(AfterEvaluatorDefinition.java:321)
>>>>
>>>> So, the attached rule is not the source of the problem, although it
>>>> might be the rule "triggering" the problem because of the event forwarding
>>>> in the consequence. Remember that the After operator is supposed to work on
>>>> events, java.util.Date, and long (for timestamps). Anything else will raise
>>>> errors.
>>>>
>>>> Finally, on a different subject, you can simplify your consequence,
>>>> as this:
>>>>
>>>>
>>>> WorkingMemoryEntryPoint eventsignaturestream =
>>>> drools.getEntryPoint("EVENT SIGNATURE STREAM") ;
>>>> eventsignaturestream.insert($p);
>>>>
>>>> Is the same as:
>>>>
>>>> entryPoints["EVENT SIGNATURE STREAM"].insert( $p );
>>>>
>>>> []s
>>>> Edson
>>>>
>>>> 2009/11/9 Chetan Mahadev <mahadev.chetan at gmail.com>
>>>>
>>>>>
>>>>> Hi I am getting the following error while inserting into the
>>>>> entrypoint.
>>>>>
>>>>> rule "Check if EligibleAlert is an Signature Event"
>>>>> agenda-group "enrichment"
>>>>> auto-focus true
>>>>>
>>>>> no-loop true
>>>>> when
>>>>> $list : EventSignatureList();
>>>>> $p : EligibleAlert($a : alert,
>>>>> $a.eventSignatureProcessingStatus!="TRUE" );
>>>>> eval((ifMatchesSyslog($list.getAllSyslogMnemonics(), $a)!=null) )
>>>>>
>>>>> then
>>>>> try{
>>>>> WorkingMemoryEntryPoint eventsignaturestream =
>>>>> drools.getEntryPoint("EVENT SIGNATURE STREAM") ;
>>>>> eventsignaturestream.insert($p);
>>>>> } catch(Exception e)
>>>>> {
>>>>> log.error("[EventSignatureRules] - exception in Check if
>>>>> EligibleAlert is an Signature Event alert[ids=" + $p.getAlert().getId() +
>>>>> "][error:" + e.toString() + "]");
>>>>> }
>>>>> end
>>>>>
>>>>> And I am creating the session this way:
>>>>> *
>>>>> knowledgeBaseConfig =
>>>>> KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
>>>>> knowledgeBaseConfig.setOption( EventProcessingOption.STREAM );
>>>>> kBase = KnowledgeBaseFactory.newKnowledgeBase(
>>>>> knowledgeBaseConfig );
>>>>>
>>>>>
>>>>>
>>>>> kBase.addKnowledgePackages(knowledgeBuilder.getKnowledgePackages());
>>>>>
>>>>>
>>>>> KnowledgeSessionConfiguration knowledgeSessionConfig =
>>>>> KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
>>>>> ((SessionConfiguration) knowledgeSessionConfig).setClockType(
>>>>> ClockType.REALTIME_CLOCK );
>>>>>
>>>>> kBase.newStatefulKnowledgeSession(knowledgeSessionConfig,null);*
>>>>>
>>>>>
>>>>> I get the Following error when my rule fires:
>>>>>
>>>>> 2009-11-09 15:02:00,675 FATAL pool-2-thread-1 LogStream -
>>>>> java.lang.ClassCastException: org.drools.common.DefaultFactHandle cannot be
>>>>> cast to org.drools.common.EventFactHandle
>>>>> 2009-11-09 15:02:00,676 FATAL pool-2-thread-1 LogStream - at
>>>>> org.drools.base.evaluators.AfterEvaluatorDefinition$AfterEvaluator.evaluateCachedRight(AfterEvaluatorDefinition.java:321)
>>>>> 2009-11-09 15:02:00,676 FATAL pool-2-thread-1 LogStream - at
>>>>> org.drools.rule.VariableRestriction.isAllowedCachedRight(VariableRestriction.java:116)
>>>>> 2009-11-09 15:02:00,676 FATAL pool-2-thread-1 LogStream - at
>>>>> org.drools.rule.VariableConstraint.isAllowedCachedRight(VariableConstraint.java:112)
>>>>> 2009-11-09 15:02:00,676 FATAL pool-2-thread-1 LogStream - at
>>>>> org.drools.common.DefaultBetaConstraints.isAllowedCachedRight(DefaultBetaConstraints.java:200)
>>>>> 2009-11-09 15:02:00,676 FATAL pool-2-thread-1 LogStream - at
>>>>> org.drools.reteoo.JoinNode.assertObject(JoinNode.java:172)
>>>>> 2009-11-09 15:02:00,676 FATAL pool-2-thread-1 LogStream - at
>>>>> org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:42)
>>>>> 2009-11-09 15:02:00,676 FATAL pool-2-thread-1 LogStream - at
>>>>> org.drools.reteoo.PropagationQueuingNode$AssertAction.execute(PropagationQueuingNode.java:326)
>>>>> 2009-11-09 15:02:00,676 FATAL pool-2-thread-1 LogStream - at
>>>>> org.drools.reteoo.PropagationQueuingNode.propagateActions(PropagationQueuingNode.java:221)
>>>>> 2009-11-09 15:02:00,676 FATAL pool-2-thread-1 LogStream - at
>>>>> org.drools.reteoo.PropagationQueuingNode$PropagateAction.execute(PropagationQueuingNode.java:394)
>>>>> 2009-11-09 15:02:00,676 FATAL pool-2-thread-1 LogStream - at
>>>>> org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:1486)
>>>>> 2009-11-09 15:02:00,676 FATAL pool-2-thread-1 LogStream - at
>>>>> org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:158)
>>>>> 2009-11-09 15:02:00,676 FATAL pool-2-thread-1 LogStream - at
>>>>> org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:122)
>>>>> 2009-11-09 15:02:00,676 FATAL pool-2-thread-1 LogStream - at
>>>>> org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:80)
>>>>> 2009-11-09 15:02:00,676 FATAL pool-2-thread-1 LogStream - at
>>>>> org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:28)
>>>>> 2009-11-09 15:02:00,676 FATAL pool-2-thread-1 LogStream - at
>>>>> pnoc.alertProcessor.Rule_Check_if_EligibleAlert_is_an_Signature_Event_0.consequence(Rule_Check_if_EligibleAlert_is_an_Signature_Event_0.java:16)
>>>>> 2009-11-09 15:02:00,676 FATAL pool-2-thread-1 LogStream - at
>>>>> pnoc.alertProcessor.Rule_Check_if_EligibleAlert_is_an_Signature_Event_0ConsequenceInvoker.evaluate(Rule_Check_if_EligibleAlert_is_an_Signature_Event_0ConsequenceInvoker.java:24)
>>>>>
>>>>> Pls help!
>>>>>
>>>>>
>>>>> Regds
>>>>> Chetan
>>>>>
>>>>> _______________________________________________
>>>>> rules-users mailing list
>>>>> rules-users at lists.jboss.org
>>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Edson Tirelli
>>>> JBoss Drools Core Development
>>>> JBoss by Red Hat @ www.jboss.com
>>>>
>>>> _______________________________________________
>>>> rules-users mailing list
>>>> rules-users at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>
>>>>
>>>
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>>
>>
>>
>> --
>> Edson Tirelli
>> JBoss Drools Core Development
>> JBoss by Red Hat @ www.jboss.com
>>
>> _______________________________________________
>> 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/20091110/9c7f2687/attachment.html
More information about the rules-users
mailing list