[rules-users] NPE with enum?

Andrew Robinson andrew.rw.robinson at gmail.com
Fri Dec 21 23:26:03 EST 2007


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



More information about the rules-users mailing list