Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-3579

scala case class, Option field and mvel : unable to resolve method using strict-mode

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 5.5.0.Beta1
    • 5.3.1.Final, 5.3.2.Final, 5.4.0.Final
    • drools-compiler
    • None
    • Workaround Exists
    • Hide

      with a cast operation such as :
      address.get.town becomes ((Address)address.get).town
      But this is not satisfactory.

      Show
      with a cast operation such as : address.get.town becomes ((Address)address.get).town But this is not satisfactory.

    Description

      case class Address(street:String, town:String, country:String)
      case class Home(someone:Someone, address:Option[Address])

      rule "Who live at London"
      when
      $someone:Someone($name:name)
      Home(someone == $someone, address.isDefined, address.get.town == "London")
      then
      insert(new InformationRequest($someone, $name+" lives in London"))
      end

      address.get is seen as a java.lang.Object, not an "Address". The reported error is :

      $ sbt run
      [info] Loading project definition from /home/dcr/dev-new/scala-drools-dummy-project/project
      [info] Set current project to ScalaDroolsDummyProject (in build file:/home/dcr/dev-new/scala-drools-dummy-project/)
      [info] Running dummy.Dummy
      Unable to Analyse Expression address.get.town:
      [Error: unable to resolve method using strict-mode: java.lang.Object.town()]
      [Near :

      {... address.get.town ....}

      ]
      ^
      [Line: 61, Column: 49] : [Rule name='Who live at London']

      Although I've set mvel strict to false :

      System.setProperty("drools.dialect.mvel.strict", "false")

      Attachments

        Activity

          People

            mfusco@redhat.com Mario Fusco
            davcro Crosson David (Inactive)
            Archiver:
            rhn-support-ceverson Clark Everson

            Dates

              Created:
              Updated:
              Resolved:
              Archived:

              PagerDuty