[
http://jira.jboss.com/jira/browse/JBRULES-382?page=all ]
Edson Tirelli resolved JBRULES-382.
-----------------------------------
Resolution: Rejected
Assignee: Edson Tirelli (was: Mark Proctor)
The system is working fine. The problem was in the data used by the test program.
As you can see in the program provided, there is no methods equals() and hashcode()
implemented for the Lesson class. This means, it will use instance identity to evaluate
equality (as per inherited method from Object).
The input data used by the program includes things like this:
<net.sf.tabudrool.domain.Lesson id="lesson6">
<teacher reference="teacher1"/>
<group reference="group1"/>
<timeslot reference="timeslot0"/>
</net.sf.tabudrool.domain.Lesson>
<net.sf.tabudrool.domain.Lesson id="lesson7">
<teacher reference="teacher1"/>
<group reference="group1"/>
<timeslot reference="timeslot0"/>
</net.sf.tabudrool.domain.Lesson>
As you can see, there are 2 different lesson instances in the input data (lesson 6 and
lesson 7) configured with the same values for teacher, group and timeslot. But the
toString() method shows only the attributes, not the actual instance ID, what seems at
first site that JBRules is matching 2 equal instances when in fact they are completelly
different instances with the same attribute values.
Rule that operates on 2 facts uses the same fact for both arguments
-------------------------------------------------------------------
Key: JBRULES-382
URL:
http://jira.jboss.com/jira/browse/JBRULES-382
Project: JBoss Rules
Issue Type: Bug
Security Level: Public(Everyone can see)
Reporter: Geoffrey De Smet
Assigned To: Edson Tirelli
Priority: Minor
Fix For: 3.0.3
Attachments: JBRULES-382.zip
According to a reply on the thread "[drools-user] A few beginner drl
questions" in the user mailing list, this is a bug.
Rule:
rule secondRule
when
$lesson1 : Lesson($teacher : teacher, $group : group, $timeslot : timeslot)
$lesson2 : Lesson(teacher == $teacher, group == $group, timeslot == $timeslot)
then
System.out.println("secondRule: " + $lesson1 + " with " +
$lesson2);
end
gives an output where both lessons are the same fact:
secondRule: 0: teacher1 + group1 with 0: teacher1 + group1
I 'll attack a zip of my m2 configured app. To repreduce:
- mvn install eclipse:eclipse idea:idea
- Run net.sf.tabudrool.app.TabudroolApp
- Click "Load unsolvedSchedule1.xml"
- Click "Plan schedule"
You'll get this output, which proves that the same lesson is used both facts of the
rule:
C:\develop\build\jdk1.5.0_05\bin\java -Didea.launcher.port=7546
"-Didea.launcher.bin.path=C:\develop\edit\IntelliJ IDEA 5.1\bin"
-Dfile.encoding=UTF-8 -classpath
"C:\develop\build\jdk1.5.0_05\jre\lib\charsets.jar;C:\develop\build\jdk1.5.0_05\jre\lib\deploy.jar;C:\develop\build\jdk1.5.0_05\jre\lib\javaws.jar;C:\develop\build\jdk1.5.0_05\jre\lib\jce.jar;C:\develop\build\jdk1.5.0_05\jre\lib\jsse.jar;C:\develop\build\jdk1.5.0_05\jre\lib\plugin.jar;C:\develop\build\jdk1.5.0_05\jre\lib\rt.jar;C:\develop\build\jdk1.5.0_05\jre\lib\ext\dnsns.jar;C:\develop\build\jdk1.5.0_05\jre\lib\ext\localedata.jar;C:\develop\build\jdk1.5.0_05\jre\lib\ext\sunjce_provider.jar;C:\develop\build\jdk1.5.0_05\jre\lib\ext\sunpkcs11.jar;D:\projects\sf\tabudrool\target\test-classes;D:\projects\sf\tabudrool\target\classes;C:\Documents
and Settings\ge0ffrey\.m2\repository\junit\junit\3.8.1\junit-3.8.1.jar;C:\Documents and
Settings\ge0ffrey\.m2\repository\org\apache\commons\commons-jci-eclipse\3.2.0.666\commons-jci-eclipse-3.2.0.666.jar;C:\Documents
and
Settings\ge0ffrey\.m2\repository\concurrent\concurrent\1.3.4\concurrent-1.3.4.jar;C:\Documents
and
Settings\ge0ffrey\.m2\repository\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;C:\Documents
and
Settings\ge0ffrey\.m2\repository\javax\transaction\jta\1.0.1B\jta-1.0.1B.jar;C:\Documents
and Settings\ge0ffrey\.m2\repository\xstream\xstream\1.1.3\xstream-1.1.3.jar;C:\Documents
and
Settings\ge0ffrey\.m2\repository\org\apache\commons\commons-jci-janino\2.4.3\commons-jci-janino-2.4.3.jar;C:\Documents
and
Settings\ge0ffrey\.m2\repository\commons-logging\commons-logging\1.0.4\commons-logging-1.0.4.jar;C:\Documents
and Settings\ge0ffrey\.m2\repository\log4j\log4j\1.2.12\log4j-1.2.12.jar;C:\Documents and
Settings\ge0ffrey\.m2\repository\janino\janino\2.4.3\janino-2.4.3.jar;C:\Documents and
Settings\ge0ffrey\.m2\repository\antlr\stringtemplate\2.3b6\stringtemplate-2.3b6.jar;C:\Documents
and Settings\ge0ffrey\.m2\repository\colt\colt\1.2.0\colt-1.2.0.jar;C:\Documents and
Settings\ge0ffrey\.m2\repository\xpp3\xpp3\1.1.3.4.O\xpp3-1.1.3.4.O.jar;C:\Documents and
Settings\ge0ffrey\.m2\repository\com\servlets\cos\05Nov2002\cos-05Nov2002.jar;C:\Documents
and
Settings\ge0ffrey\.m2\repository\commons-lang\commons-lang\2.1\commons-lang-2.1.jar;C:\Documents
and Settings\ge0ffrey\.m2\repository\antlr\antlr\2.7.6\antlr-2.7.6.jar;C:\Documents and
Settings\ge0ffrey\.m2\repository\commons-collections\commons-collections\3.1\commons-collections-3.1.jar;C:\Documents
and
Settings\ge0ffrey\.m2\repository\org\springframework\spring-remoting\1.2.6\spring-remoting-1.2.6.jar;C:\Documents
and
Settings\ge0ffrey\.m2\repository\javax\resource\connector\1.0\connector-1.0.jar;C:\Documents
and Settings\ge0ffrey\.m2\repository\javax\servlet\jstl\1.0\jstl-1.0.jar;C:\Documents and
Settings\ge0ffrey\.m2\repository\org\springframework\spring-core\1.2.6\spring-core-1.2.6.jar;C:\Documents
and Settings\ge0ffrey\.m2\repository\quartz\quartz\1.5.1\quartz-1.5.1.jar;C:\Documents and
Settings\ge0ffrey\.m2\repository\taglibs\standard\1.0.6\standard-1.0.6.jar;C:\Documents
and Settings\ge0ffrey\.m2\repository\oro\oro\2.0.8\oro-2.0.8.jar;C:\Documents and
Settings\ge0ffrey\.m2\repository\xerces\xercesImpl\2.6.2\xercesImpl-2.6.2.jar;C:\Documents
and
Settings\ge0ffrey\.m2\repository\org\springframework\spring-orm\1.2.6\spring-orm-1.2.6.jar;C:\Documents
and
Settings\ge0ffrey\.m2\repository\commons-io\commons-io\1.1\commons-io-1.1.jar;C:\Documents
and
Settings\ge0ffrey\.m2\repository\org\springframework\spring-web\1.2.6\spring-web-1.2.6.jar;C:\Documents
and
Settings\ge0ffrey\.m2\repository\org\springframework\spring-beans\1.2.6\spring-beans-1.2.6.jar;C:\Documents
and
Settings\ge0ffrey\.m2\repository\org\springframework\spring-context\1.2.6\spring-context-1.2.6.jar;C:\Documents
and
Settings\ge0ffrey\.m2\repository\javax\activation\activation\1.0.2\activation-1.0.2.jar;C:\Documents
and Settings\ge0ffrey\.m2\repository\jung\jung\1.7.2\jung-1.7.2.jar;C:\Documents and
Settings\ge0ffrey\.m2\repository\org\springframework\spring-support\1.2.6\spring-support-1.2.6.jar;C:\Documents
and
Settings\ge0ffrey\.m2\repository\org\springframework\spring-webmvc\1.2.6\spring-webmvc-1.2.6.jar;C:\Documents
and
Settings\ge0ffrey\.m2\repository\org\springframework\spring-aop\1.2.6\spring-aop-1.2.6.jar;C:\Documents
and Settings\ge0ffrey\.m2\repository\ehcache\ehcache\1.1\ehcache-1.1.jar;C:\Documents and
Settings\ge0ffrey\.m2\repository\org\springframework\spring-dao\1.2.6\spring-dao-1.2.6.jar;C:\Documents
and
Settings\ge0ffrey\.m2\repository\org\drools\drools-compiler\3.0.3\drools-compiler-3.0.3.jar;C:\Documents
and
Settings\ge0ffrey\.m2\repository\org\eclipse\jdt\core\3.2.0.666\core-3.2.0.666.jar;C:\Documents
and Settings\ge0ffrey\.m2\repository\org\antlr\antlr\3.0ea8\antlr-3.0ea8.jar;C:\Documents
and
Settings\ge0ffrey\.m2\repository\org\apache\commons\commons-jci-core\1.0-406301\commons-jci-core-1.0-406301.jar;C:\Documents
and
Settings\ge0ffrey\.m2\repository\org\springframework\spring-jdbc\1.2.6\spring-jdbc-1.2.6.jar;C:\Documents
and
Settings\ge0ffrey\.m2\repository\commons-logging\commons-logging-api\1.0.4\commons-logging-api-1.0.4.jar;C:\Documents
and Settings\ge0ffrey\.m2\repository\javax\mail\mail\1.3.2\mail-1.3.2.jar;C:\Documents and
Settings\ge0ffrey\.m2\repository\org\drools\drools-core\3.0.3\drools-core-3.0.3.jar;C:\develop\edit\IntelliJ
IDEA 5.1\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain
net.sf.tabudrool.app.TabudroolApp
2006-07-30 17:13:45,062 [AWT-EventQueue-0] INFO
net.sf.tabudrool.persistence.ScheduleDao.readSchedule(ScheduleDao.java:37)
Loaded: class path resource [net/sf/tabudrool/persistence/unsolvedSchedule1.xml]
secondRule: 0: teacher1 + group1 with 0: teacher1 + group1
secondRule: 0: teacher1 + group1 with 0: teacher1 + group1
secondRule: 0: teacher1 + group1 with 0: teacher1 + group1
secondRule: 0: teacher1 + group1 with 0: teacher1 + group1
secondRule: 0: teacher2 + group2 with 0: teacher2 + group2
secondRule: 0: teacher2 + group2 with 0: teacher2 + group2
secondRule: 0: teacher2 + group2 with 0: teacher2 + group2
secondRule: 0: teacher2 + group2 with 0: teacher2 + group2
secondRule: 0: teacher2 + group2 with 0: teacher2 + group2
secondRule: 0: teacher2 + group2 with 0: teacher2 + group2
secondRule: 0: teacher3 + group3 with 0: teacher3 + group3
secondRule: 0: teacher3 + group3 with 0: teacher3 + group3
secondRule: 0: teacher1 + group1 with 0: teacher1 + group1
secondRule: 0: teacher1 + group1 with 0: teacher1 + group1
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira