Re: [rules-users] Drools5.2.2 integration with scala2.9.0.1
Thank Mario, Thank a lot for the reply. The solution was really helpful and I am able to run my code. I would also like to know is there any guideline or document to debug these kind of errors, since it doesn't show any problem at compile time or runtime. Thanks, Puneet -- View this message in context: http://drools.46999.n3.nabble.com/Drools5-2-2-integration-with-scala2-9-0-1-tp3229566p3236613.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools5.2.2 integration with scala2.9.0.1
Hi, I just tried the same and indeed the code as presented in the post you linked cannot work. The problem is that MVEL tries to read the field value of the Temperature class by following the JavaBean specification, i.e. by looking for a method named getValue(). It means that if you change the method name of the Temperature trait from value to getValue the code works as expected. To be honest is quite ugly to use a Scala trait to model a domain object as done in that example. I'd rather suggest to use a case class as it follows: case class Temperature(@BeanProperty value: Int) so in this way you can create your Temperature objects as simple as: val shouldBeTooHot = Temperature(100) Note that I annotated the value field of the case class with @BeanProperty in order to tell to the Scala compiler to generate an accessor to that field that is compatible with the JavaBean specification. I created a public github project and made available the complete working example there: https://github.com/mariofusco/scaladrools I will continue enriching this project with other Scala/Drools integration attempts in my spare time. I hope this helps. Cheers, Mario Fusco -- View this message in context: http://drools.46999.n3.nabble.com/Drools5-2-2-integration-with-scala2-9-0-1-tp3229566p3231390.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Drools5.2.2 integration with scala2.9.0.1
Hi, I am new with Drools. I am integrating Drools with Scala. I am trying the project given at http://www.gettingcirrius.com/2010/12/using-jboss-rules-drools-in-scala.html http://www.gettingcirrius.com/2010/12/using-jboss-rules-drools-in-scala.html . I have made a small change in the code to supply the Drools rule file as given below: code File f = new File(WeatherRules.drl); kbuilder.add(ResourceFactory.newFileResource(f), ResourceType.DRL); /code The code is running fine and there is no error but the rules are not working. The output I got is: code Creating Knowledge Session Creating and insertng Temperature Firing all rules /code It seems that the configured rules are not working. The dependencies I am using in for is: Scala: 2.9.0.1 Sbt: 0.7.7 jaxb-xjc: 2.2.4-1 drools-core: 5.2.0.Final drools-compiler: 5.2.0.Final jxl: 2.6 xstream: 1.3.1 Am I missing something? Please help me to integrate Drools with scala. Thanks in advance. Any help will be appreciated. thanks, Puneet -- View this message in context: http://drools.46999.n3.nabble.com/Drools5-2-2-integration-with-scala2-9-0-1-tp3229566p3229566.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users