[rules-users] Problem with Banking Tutorial

Stefan Schuster stefan.m.schuster at gmail.com
Thu Apr 18 12:41:52 EDT 2013


Thanks for all answers.

Finally I found the ticket for this issue:
https://issues.jboss.org/browse/DROOLS-15

Despite all the great functionality in Drools, this bug makes me really
afraid. I can live with bugs that throw exceptions or even crash the
application. But simply returning a wrong value is the worst case I can
imagine for an algorithmic library.

 Is this such a special case that it has no effect in every days use? I
mean, this error occurs when starting one of the examples that are part of
the release, that doesn't sound like a special case to me, isn't it?

Please don't misunderstand me, I have a deep respect for the developer of
such complex systems like DROOLS, and  I know from my own code that bugs
simply happen. But I wonder why there is still this version without any
warning the official release?

Is it better to use an older version?

best regards

Stefan




2013/4/18 Mark Proctor <mproctor at codehaus.org>

> There are a lot of fixes in the 5.x master. Anyone verified their bugs
> against this? I suspect this is fixed in that.
>
>
> Mark
> On 18 Apr 2013, at 16:21, Wolfgang Laun <wolfgang.laun at gmail.com> wrote:
>
> > Ah, my memory :-)
> >
> > http://lists.jboss.org/pipermail/rules-dev/2013-January/004338.html
> >
> > Mark has promised a fix for 3 months ago, but of course 5.5.0 remains
> broken.
> >
> > -W
> >
> > On 18/04/2013, Stefan Schuster <stefan.m.schuster at gmail.com> wrote:
> >> Hi, thank you for your response.
> >> I'm using the latest stable release of Drools 5.5.0 final.
> >> Eclipse is Juno Service Release 2.
> >>
> >> Can you confirm, that the order 1,2,3 is the expected result?
> >>
> >> If this is a known bug, is there some kind of jira or bugzilla numer
> >> assigned to it?
> >>
> >>
> >>
> >> 2013/4/18 Wolfgang Laun <wolfgang.laun at gmail.com>
> >>
> >>> IIRC, this was a bug one or two minor versions ago. What version are
> you
> >>> using?
> >>> -W
> >>>
> >>> On 18/04/2013, Stefan Schuster <stefan.m.schuster at gmail.com> wrote:
> >>>> For the sake of  completeness, here is also the RuleRunner class used
> >>>> in
> >>>> this example:
> >>>>
> >>>> package org.drools.tutorials.banking;
> >>>>
> >>>> import java.util.Collection;
> >>>>
> >>>> import org.drools.KnowledgeBase;
> >>>> import org.drools.KnowledgeBaseFactory;
> >>>> import org.drools.builder.KnowledgeBuilder;
> >>>> import org.drools.builder.KnowledgeBuilderFactory;
> >>>> import org.drools.builder.ResourceType;
> >>>> import org.drools.definition.KnowledgePackage;
> >>>> import org.drools.io.ResourceFactory;
> >>>> import org.drools.runtime.StatefulKnowledgeSession;
> >>>>
> >>>> public class RuleRunner {
> >>>>
> >>>>    public RuleRunner() {
> >>>>    }
> >>>>
> >>>>    public void runRules(String[] rules,
> >>>>                         Object[] facts) {
> >>>>
> >>>>        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
> >>>>        KnowledgeBuilder kbuilder =
> >>>> KnowledgeBuilderFactory.newKnowledgeBuilder();
> >>>>
> >>>>        for ( int i = 0; i < rules.length; i++ ) {
> >>>>            String ruleFile = rules[i];
> >>>>            System.out.println( "Loading file: " + ruleFile );
> >>>>            kbuilder.add( ResourceFactory.newClassPathResource(
> >>>> ruleFile,
> >>>>
> >>>> RuleRunner.class ),
> >>>>                                  ResourceType.DRL );
> >>>>        }
> >>>>
> >>>>        Collection<KnowledgePackage> pkgs =
> >>>> kbuilder.getKnowledgePackages();
> >>>>        kbase.addKnowledgePackages( pkgs );
> >>>>        StatefulKnowledgeSession ksession =
> >>>> kbase.newStatefulKnowledgeSession();
> >>>>
> >>>>        for ( int i = 0; i < facts.length; i++ ) {
> >>>>            Object fact = facts[i];
> >>>>            System.out.println( "Inserting fact: " + fact );
> >>>>            ksession.insert( fact );
> >>>>        }
> >>>>
> >>>>        ksession.fireAllRules();
> >>>>    }
> >>>> }
> >>>>
> >>>>
> >>>> 2013/4/18 Stefan Schuster <stefan.m.schuster at gmail.com>
> >>>>
> >>>>> Hello,
> >>>>>
> >>>>> I have a problem with the banking tutorial number 3, which is part of
> >>> the
> >>>>> examples of drools expert.
> >>>>> It simply adds some Numbers as facts, and retracts them in an
> >>>>> increasing
> >>>>> order.
> >>>>>
> >>>>> It is very short, therefore I post the whole Code:
> >>>>>
> >>>>>
> >>>>> BankingExample3.java
> >>>>> _________________________________________________
> >>>>> package org.drools.tutorials.banking;
> >>>>>
> >>>>> public class BankingExample3 {
> >>>>>    public static void main(String[] args) {
> >>>>>        Number[] numbers = new Number[] {wrap(3), wrap(1), wrap(4),
> >>>>> wrap(1), wrap(5)};
> >>>>>        new RuleRunner().runRules( new String[] { "Example3.drl" },
> >>>>>                                   numbers );
> >>>>>    }
> >>>>>
> >>>>>    private static Integer wrap(int i) {
> >>>>>        return new Integer(i);
> >>>>>    }
> >>>>> }
> >>>>> _________________________________________________
> >>>>>
> >>>>>
> >>>>>
> >>>>> Example3.drl:
> >>>>> _________________________________________________
> >>>>> package org.drools.tutorials.banking
> >>>>>
> >>>>> rule "Rule 01"
> >>>>>    when
> >>>>>        $number : Number()
> >>>>>        not Number( intValue < $number.intValue )
> >>>>>    then
> >>>>>        System.out.println("Number found with value: " +
> >>>>> $number.intValue() );
> >>>>>        retract( $number );
> >>>>> end
> >>>>> _________________________________________________
> >>>>>
> >>>>>
> >>>>> Output:
> >>>>> _________________________________________________
> >>>>> Loading file: Example3.drl
> >>>>> Inserting fact: 3
> >>>>> Inserting fact: 1
> >>>>> Inserting fact: 4
> >>>>> Inserting fact: 1
> >>>>> Inserting fact: 5
> >>>>> Number found with value: 1
> >>>>> Number found with value: 1
> >>>>> Number found with value: 3
> >>>>> Number found with value: 4
> >>>>> Number found with value: 5
> >>>>> _________________________________________________
> >>>>>
> >>>>>
> >>>>> that seams absolute logically to me.
> >>>>> But now I alter the Numbers in the Java-Part:
> >>>>> Number[] numbers = new Number[] {wrap(3), wrap(1), wrap(2)};
> >>>>>
> >>>>> and the output destroys everything I thought I understood:
> >>>>> Loading file: Example3.drl
> >>>>> Inserting fact: 3
> >>>>> Inserting fact: 1
> >>>>> Inserting fact: 2
> >>>>> Number found with value: 1
> >>>>> Number found with value: 3
> >>>>> Number found with value: 2
> >>>>>
> >>>>>
> >>>>> Can someone  reproduce this behavior?? It seams absolutely strange to
> >>> me.
> >>>>> I would have expected the order 1,2,3. Any explanations?
> >>>>>
> >>>>> Thanks in advance for helping me!
> >>>>>
> >>>>>
> >>>>>
> >>>>
> >>> _______________________________________________
> >>> 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
>
>
> _______________________________________________
> 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/20130418/0fbb62ae/attachment.html 


More information about the rules-users mailing list