[jboss-jira] [JBoss JIRA] (DROOLS-387) NoSuchElementException on addKnowledgePackages when a "not" follows an "eval"

Davide Sottara (JIRA) issues at jboss.org
Thu Jan 2 15:49:32 EST 2014


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

Davide Sottara closed DROOLS-387.
---------------------------------

    Resolution: Done

    
> NoSuchElementException on addKnowledgePackages when a "not" follows an "eval"
> -----------------------------------------------------------------------------
>
>                 Key: DROOLS-387
>                 URL: https://issues.jboss.org/browse/DROOLS-387
>             Project: Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 5.5.0.Final
>         Environment: java version "1.7.0_21"
>            Reporter: Jason Saint
>            Assignee: Mark Proctor
>
> I apologize if this has already been reported, but I did not see anything in search results for which this looked like a duplicate.
> With the following 2 rules, compiling the first and adding it to a knowledge base causes subsequent package additions to fail with a NoSuchElementException.
> rule "Problem"
>   when
>     eval(true == true)
>     not String() from "Problem"
>   then
> end
> rule "Test1"
>   when
>     $test : String() from "Test"
>   then
> end
> The following java code will produce the exception on the second call to addKnowledgePackages (tried with Drools 5.4 and 5.5)
> {code}
> package com.chiprewards.droolsbug;
> import org.drools.KnowledgeBase;
> import org.drools.KnowledgeBaseFactory;
> import org.drools.builder.KnowledgeBuilder;
> import org.drools.builder.KnowledgeBuilderErrors;
> import org.drools.builder.KnowledgeBuilderFactory;
> import org.drools.io.Resource;
> import org.drools.builder.ResourceType;
> import org.drools.io.ResourceFactory;
> /**
>  * Hello world!
>  *
>  */
> public class App 
> {
>     public static void main( String[] args )
>     {        
>         KnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase();
>         KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
>         
>         String problem_rule = "rule \"Problem\"\n  when\n    eval(true == true)\n    not String() from \"Problem\"\n  then\nend";
>         
>         Resource resource = ResourceFactory.newByteArrayResource(problem_rule.getBytes());
>         kbuilder.add(resource, ResourceType.DRL);
>         if(kbuilder.hasErrors()) {
>             System.out.println("First rule had error parsing");
>             System.exit(1);
>         }
>         
>         kBase.addKnowledgePackages(kbuilder.getKnowledgePackages());
>         
>         //Add second rule
>         
>         String next_rule = "rule \"Test\"\n  when\n    String() from \"Test\"\n  then\nend";
>         
>         resource = ResourceFactory.newByteArrayResource(next_rule.getBytes());
>         kbuilder.add(resource, ResourceType.DRL);
>         if(kbuilder.hasErrors()) {
>             System.out.println("Second rule had error parsing");
>             System.exit(1);
>         }
>         
>         kBase.addKnowledgePackages(kbuilder.getKnowledgePackages());       
>     }
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list