[rules-users] NPE with enum?

Andrew Robinson andrew.rw.robinson at gmail.com
Mon Dec 24 13:10:46 EST 2007


It wasn't a top level -- the and was necessary

I just found the issue. I got this test output mixed up with another
test. It turns out it was a dumb user error. The permissions list was
null!

Sorry for the trouble.

-Andrew

On Dec 24, 2007 9:27 AM, Mark Proctor <mproctor at codehaus.org> wrote:
> The 'and' is redundant, it's implicitely implied for top level patterns
>
>       $rt: ResourceType( )
>       $perm: ResourceTypePermission( accessType != AccessType.READ ) from $rt.permissions
>       com.christws.entities.Role($rolename: name) from $perm.role
>       Role(name == $rolename)
>
> Can you make a small self contained test and upload it as a jira for us.
>
> Thanks
>
> Mark
>
>
> Andrew Robinson wrote:
> > I have an enumeration called AccessType:
> > public enum AccessType
> > {
> >   READ,
> >   UPDATE,
> >   DELETE
> > }
> >
> > In a rule, I have:
> >       $rt: ResourceType( )
> >       and $perm: ResourceTypePermission( accessType != AccessType.READ
> > ) from $rt.permissions
> >       and com.christws.entities.Role($rolename: name) from $perm.role
> >       and Role(name == $rolename)
> >
> > I am getting the following exception:
> > java.lang.NullPointerException
> >       at org.drools.base.com.christws.entities.ResourceTypePermission7859095$getAccessType.getValue(Unknown
> > Source)
> >       at org.drools.base.ClassFieldExtractor.getValue(ClassFieldExtractor.java:127)
> >       at org.drools.base.evaluators.ObjectFactory$ObjectNotEqualEvaluator.evaluate(ObjectFactory.java:175)
> >       at org.drools.rule.LiteralRestriction.isAllowed(LiteralRestriction.java:61)
> >       at org.drools.rule.LiteralConstraint.isAllowed(LiteralConstraint.java:82)
> >       at org.drools.reteoo.FromNode.assertTuple(FromNode.java:73)
> >       at org.drools.reteoo.SingleTupleSinkAdapter.propagateAssertTuple(SingleTupleSinkAdapter.java:20)
> >       at org.drools.reteoo.JoinNode.assertObject(JoinNode.java:149)
> >       at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:22)
> >       at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:153)
> >       at org.drools.reteoo.Rete.assertObject(Rete.java:177)
> >       at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
> >       at org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:71)
> >       at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:886)
> >       at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:858)
> >       at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:659)
> >       at org.jboss.seam.security.RuleBasedIdentity.hasPermission(RuleBasedIdentity.java:143)
> >       at org.jboss.seam.security.Identity.checkPermission(Identity.java:474)
> >
> > The accessType is not null (checked with the debugger). Do you know
> > why I would be getting this? If it matters, the getAccessType method
> > and the accessType field are defined in an abstract super class of
> > ResourceTypePermission (ResourceTypePermission extends RolePermission
> > extends Permission which has the field)
> >
> > drools version 4.0.3
> >
> > -Andrew
> > _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



More information about the rules-users mailing list