Problem cancelling timers after upgrade to OH2

I’ve just upgraded to openHAB2 and have a couple of rules with code like this:

if (pir_movement_idle != null) {
    pir_movement_idle = null

I’m getting an error “Could not invoke method: java.util.Timer.cancel() on instance: org.eclipse.smarthome.model.script.internal.actions.TimerImpl@b34f33”. I searched for this error in here and found no reference to it.

The timer variable is declared globally outside the rule.

Any ideas?

Tip from this post

Remove any Timer import at the head of the rule file - not needed in OH2

Thanks - will give it a try.

I removed a bunch of other imports but this wasn’t one of them that was mentioned in the upgrade tutorial.