[jboss-jira] [JBoss JIRA] (JBRULES-3240) Unable to build expression for 'inline-eval' when using Lists of objects

Tibor Zimányi (JIRA) issues at jboss.org
Tue Jul 10 09:39:01 EDT 2018


     [ https://issues.jboss.org/browse/JBRULES-3240?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tibor Zimányi closed JBRULES-3240.
----------------------------------
    Resolution: Out of Date


This project is not active anymore. The current active project is "DROOLS". Closing this.

> Unable to build expression for 'inline-eval' when using Lists of objects
> ------------------------------------------------------------------------
>
>                 Key: JBRULES-3240
>                 URL: https://issues.jboss.org/browse/JBRULES-3240
>             Project: JBRULES
>          Issue Type: Bug
>          Components: drools-compiler
>    Affects Versions: 5.3.0.CR1
>         Environment: Ubuntu, JDK 1.6.0.26
>            Reporter: Richard Ambridge
>            Assignee: Mario Fusco
>             Fix For: 6.0.0.Alpha1
>
>
> If a Rule has a .size== in when and the variable is an Object, then we get the following:-
> Unable to build expression for 'inline-eval' : [Error: incompatible types in statement: class java.lang.Integer (compared from: class droolstesting.SubType)]
> Full example:
> Rule:
> package droolstesting
> rule "rule2"
> dialect "mvel"
> when
>   $m : MyItem(items!=null || items.size == 0)
> then
>   System.out.println("Got 0");
>   retract($m)
> end
> MyItems.java:
> package droolstesting;
> import java.util.ArrayList;
> import java.util.List;
> public class MyItem {
>     int number=0;
>     String string="empty";
>     List<SubType> items=new ArrayList<SubType>();
>     public List<SubType> getItems() {
>         return items;
>     }
>     public void setItems(List<SubType> items) {
>         this.items = items;
>     }
>     public int getNumber() {
>         return number;
>     }
>     public void setNumber(int number) {
>         this.number = number;
>     }
>     public String getString() {
>         return string;
>     }
>     public void setString(String string) {
>         this.string = string;
>     }
> }
> SubType.java:
> package droolstesting;
> public class SubType {
>    String name="";
>    
> }
> Main.java:
> package droolstesting;
> import java.io.File;
> import java.io.IOException;
> import org.drools.compiler.DroolsParserException;
> import org.drools.compiler.PackageBuilder;
> import org.drools.io.ResourceFactory;
> /**
>  *
>  * @author richarda
>  */
> public class Main {
>     /**
>      * @param args the command line arguments
>      */
>     public static void main(String[] args) throws IOException, DroolsParserException {
>         PackageBuilder pkgBuilder = new PackageBuilder();
>         pkgBuilder.addPackageFromDrl(ResourceFactory.newClassPathResource("rule1.drl"));
>         if (pkgBuilder.hasErrors()) {
>             System.err.println(pkgBuilder.getErrors().toString());
>             throw new RuntimeException("Unable to compile rules");
>         }
>         pkgBuilder.addPackageFromDrl(ResourceFactory.newClassPathResource("rule2.drl"));
>         if (pkgBuilder.hasErrors()) {
>             System.err.println(pkgBuilder.getErrors().toString());
>             throw new RuntimeException("Unable to compile rules");
>         }
>     }
> }
> Result:
> run:
> Unable to build expression for 'inline-eval' : [Error: incompatible types in statement: class java.lang.Integer (compared from: class droolstesting.SubType)]
> [Near : {... items != null || items.size == 0 ....}]
>                               ^
> [Line: 6, Column: 14]'items != null || items.size == 0'
> [Error: incompatible types in statement: class java.lang.Integer (compared from: class droolstesting.SubType)]
> [Near : {... items != null || items.size == 0 ....}]
>                               ^
> [Line: 6, Column: 14] : [Rule name='rule2']
> [Error: incompatible types in statement: class java.lang.Integer (compared from: class droolstesting.SubType)]
> [Near : {... items != null || items.size == 0 ....}]
>                               ^
> [Line: 1, Column: 18]
> Exception in thread "main" java.lang.RuntimeException: Unable to compile rules
>         at droolstesting.Main.main(Main.java:32)
> Java Result: 1
> BUILD SUCCESSFUL (total time: 1 second)



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)



More information about the jboss-jira mailing list