You can't use a binding with exists. When you think about it it makes sense - if there were more than one Employed object in working memory which one would be used?
cheers
Steve
On 11/14/06, nicolae oana <[EMAIL PROTECTED]> wrote:
Hello all!
I better test my rules and the exception cames from the next one:
rule "existFact"
when
exists(Employed(emp:employedID))
then
System.out.println("iteratie exists-fact --- name:"+emp);
end
When I print the declaration emp, the exception is:
Exception in thread "main" org.drools.rule.InvalidRulePackage: Rule Compilation error emp cannot be resolved
at org.drools.rule.Package.checkValidity (Unknown Source)
at org.drools.common.AbstractRuleBase.addPackage(Unknown Source)
at example.RuleWithEmployes.main(RuleWithEmployes.java:33)
When I don't print the declaration emp, just a simple string message I get this error ( for the same rule):
Exception in thread "main" java.lang.NullPointerException at org.drools.base.example.RuleWithEmployes$Employed$getEmployedID.getValue(Unknown Source)
at org.drools.base.ClassFieldExtractor.getValue(Unknown Source)
at org.drools.rule.Declaration.getValue(Unknown Source)
at org.drools.audit.WorkingMemoryLogger.extractDeclarations(Unknown Source)
at org.drools.audit.WorkingMemoryLogger.activationCreated(Unknown Source)
at org.drools.event.AgendaEventSupport.fireActivationCreated (Unknown Source)
at org.drools.reteoo.TerminalNode.assertTuple(Unknown Source)
at org.drools.reteoo.TerminalNode.assertTuple(Unknown Source)
at org.drools.reteoo.TupleSource.propagateAssertTuple(Unknown Source)
at org.drools.reteoo.NotNode.retractObject(Unknown Source)
at org.drools.reteoo.ObjectSource.propagateRetractObject(Unknown Source)
at org.drools.reteoo.RightInputAdapterNode.retractTuple(Unknown Source)
at org.drools.reteoo.TupleSource.propagateRetractTuple(Unknown Source)
at org.drools.reteoo.NotNode.assertObject(Unknown Source)
at org.drools.reteoo.ObjectSource.propagateAssertObject(Unknown Source)
at org.drools.reteoo.ObjectTypeNode.assertObject(Unknown Source)
at org.drools.reteoo.Rete.assertObject(Unknown Source)
at org.drools.reteoo.ReteooRuleBase.assertObject(Unknown Source)
at org.drools.reteoo.ReteooWorkingMemory.doAssertObject(Unknown Source)
at org.drools.common.AbstractWorkingMemory.assertObject(Unknown Source)
at org.drools.common.AbstractWorkingMemory.assertObject(Unknown Source)
at example.RuleWithEmployes.main(RuleWithEmployes.java:45)
Please tell me where I did something wrong!
Best regards, Oana.
Edson Tirelli < [EMAIL PROTECTED]> wrote:Oana,--
Your rules seems to be correct. I also copy and pasted your sample
here and it is working.
Can you send us the stack trace for the exception or maybe a self
contained test case in a way we can investigate it better?
[]s
Edson
nicolae oana wrote:
> Hi all!
>
> Please help me with this problem: I have a class Employed ( name,
> workedHours, extraHours), and two facts asserted into working memory:
>
> Employed("Susan",10,5);
> Employed("Fred",16,8);
>
> I also have two rules. First one is ok, it fires and print the
> correct results, but the second one give this error:"emp can not be
> resolved "
>
> rule "Extra Hours-Predicate _expression_"
>
> when
> Employed(employedID=="Fred", extra:extraHours)
> Employed(ext:extraHours ->(extra.intValue()==ext.intValue()+3))
> then
> System.out.println("Predicate Constraint -- extra:"+extra+"
> ext:"+ext);
> end
>
> rule "allEmployedFacts"
>
> when
> Employed(emp:employedID)
> then
> System.out.println("Name:"+emp);
> end
>
> Please tell me what can be the problem and where I did something wrong!
>
> Regards, Oana
>
> ------------------------------------------------------------------------
> Access over 1 million songs - Yahoo! Music Unlimited.
>
---
Edson Tirelli
Software Engineer - JBoss Rules Core Developer
Office: +55 11 3124-6000
Mobile: +55 11 9218-4151
JBoss, a division of Red Hat @ www.jboss.com
IT executives: Red Hat still #1 for value
http://www.redhat.com/promo/vendor/
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email
Access over 1 million songs - Yahoo! Music Unlimited.
--
Steven Williams
Supervising Consultant
Object Consulting
Office: 8615 4500 Mob: 0439 898 668 Fax: 8615 4501
[EMAIL PROTECTED]
www.objectconsulting.com.au
consulting | development | training | support
our experience makes the difference
