[jboss-jira] [JBoss JIRA] Updated: (JBRULES-1045) Predicate Null Pointer exception when using Java 5 Enum

Edson Tirelli (JIRA) jira-events at lists.jboss.org
Tue Jul 31 08:39:49 EDT 2007


     [ http://jira.jboss.com/jira/browse/JBRULES-1045?page=all ]

Edson Tirelli updated JBRULES-1045:
-----------------------------------

    Fix Version/s: 4.0.1

> Predicate Null Pointer exception when using Java 5 Enum
> -------------------------------------------------------
>
>                 Key: JBRULES-1045
>                 URL: http://jira.jboss.com/jira/browse/JBRULES-1045
>             Project: JBoss Rules
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>    Affects Versions:  4.0.0.GA
>         Environment: Windows XP sp2, Jboss Rules 4.0.0 GA, Sun Java 1.5.0_11 VM, Eclipse 3.3 with JBOss Rules IDE 4.0 
>            Reporter: christopher barham
>         Assigned To: Edson Tirelli
>             Fix For: 4.0.1
>
>
> Java 5 enums as column constraint do not work as expected.  Cqauses Null pointer exception in mvel.MVELPredicateExpression.evaluate.
> Using modified Eclipse generated  Sample project to demonstrate:
> DroolsTest now has an Enum for it's Message:
> package com.sample;
> import java.io.InputStreamReader;
> import java.io.Reader;
> import org.drools.RuleBase;
> import org.drools.RuleBaseFactory;
> import org.drools.WorkingMemory;
> import org.drools.compiler.PackageBuilder;
> import org.drools.rule.Package;
> /**
>  * This is a sample file to launch a rule package from a rule source file.
>  */
> public class DroolsTest {
>     public static final void main(String[] args) {
>         try {
>             RuleBase ruleBase = readRule();
>             WorkingMemory workingMemory = ruleBase.newStatefulSession();
>             workingMemory.insert(Message.HELLO);
>             workingMemory.fireAllRules();
>         } catch (Throwable t) {
>             t.printStackTrace();
>         }
>     }
>     private static RuleBase readRule() throws Exception {
>         // read in the source
>         Reader source = new InputStreamReader(DroolsTest.class.getResourceAsStream("/Sample.drl"));
>         PackageBuilder builder = new PackageBuilder();
>         builder.addPackageFromDrl(source);
>         Package pkg = builder.getPackage();
>         RuleBase ruleBase = RuleBaseFactory.newRuleBase();
>         ruleBase.addPackage(pkg);
>         return ruleBase;
>     }
>     public enum Message {
>         GOODBYE, HELLO;
>     }
> }
> The Sample.drl rule is modified to:
> package com.sample
> import com.sample.DroolsTest.Message;
> rule "Hello World"
>   when
>     m : Message( Message.HELLO )
>   then
>     System.out.println( m );
> end
> Stack trace given is:
> org.drools.RuntimeDroolsException: Exception executing predicate org.drools.base.mvel.MVELPredicateExpression at 10382a9
> 	at org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:197)
> 	at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:122)
> 	at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:20)
> 	at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:168)
> 	at org.drools.reteoo.Rete.assertObject(Rete.java:168)
> 	at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:190)
> 	at org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:70)
> 	at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:848)
> 	at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:822)
> 	at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:623)
> 	at com.sample.DroolsTest.main(DroolsTest.java:21)
> Caused by: java.lang.NullPointerException
> 	at org.drools.base.mvel.MVELPredicateExpression.evaluate(MVELPredicateExpression.java:39)
> 	at org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:191)
> 	... 10 more

-- 
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

        



More information about the jboss-jira mailing list