I'm not sure what you're trying to do in your rule.
The retract action is intended to remove a fact from working memory. In your code, you're trying to remove something that is not in working memory.
Here's a simple example for how this is supposed to work. Let's say we have some rules that key off of an object called MyFact that has some properties. So we have some rules that look like this:
rule "Example rule 1"
when
MyFact( value == "foo" )
then
// do something for 'foo'
end
rule "Example rule 2"
when
MyFact( value == "bar" )
then
// do something for 'bar'
end
Now, as long as we have a MyFact instance in working memory, these rules will be evaluated. So to keep these rules from firing, we can retract the fact -- but we have to retract the instance.
Example of the retraction:
rule "Retract fact when value is 'abc'"
when
$f: MyFact( value == "abc" ) // $f is the instance
then
retract($f)
end
We're not retracting arbitrary data -- we retract the specific fact instance we want to retract.
If I tried to retract something not in working memory -- then the NullPointerException makes total sense. You can't retract something that's not there, so when the Drools engine can't find the thing you've requested it throws the exception.