I've further narrowed the problem down.
I think it is because "read" is called at deployment time,
at which time the subprocessname variable (transient) is set.
Then it is not persisted, since it is transient.
At runtime the node asks for the processdefinition based on subprocessname.
If subprocessname is null at that time,so is processdefinition.
This causes the reported exception.
How must this be fixed?